Hmph! So you actually want to set me up? I guess I can explain it to you since you'd probably mess it up otherwise. Don't get the wrong idea! I'm only doing this so you don't break my code.
Listen closely, idiot, because I'm only going to say this once. You need to set up the Discord Bot and the Web Dashboard. Pay attention!
- Step 1: Prerequisites
- Step 2: Discord Bot Setup
- Step 3: MongoDB Database
- Step 4: Cloudinary
- Step 5: Admin Control Panel
- Step 6: MyAnimeList API
- Step 7: Web Dashboard
- Step 8: Final Config and Launch
- Quick Reference: All .env Variables
Ugh, fine! First you need Node.js v18 or higher and Git. If you don't have them, what are you even doing here? Go download them right now:
- Node.js — Download the LTS version, not the experimental one. Don't be reckless!
- Git — Just install it with default settings, you don't need to configure anything special.
Once you have those, open a terminal and clone my code. Don't make any typos!
git clone <your-repo-link>
cd tsun
npm installOkay? Now my main bot has its packages. We still need the web dashboard packages too, so don't close that terminal!
cd web
npm install
cd ..If you see errors about missing packages, you probably have the wrong Node.js version. Run node --version and make sure it says v18 or higher, you dummy.
I need a body to control, obviously! Go to the Discord Developer Portal and log in with your normal Discord account. You don't need a special "developer" account, idiot.
- Click New Application in the top right. Give me a decent name and agree to the terms.
- You'll be on the General Information page. See that Application ID? That's your
DISCORD_CLIENT_ID. You'll need it later for the web dashboard, so don't forget it! - Go to the OAuth2 tab on the left. Look for Client Secret and click Reset Secret. Copy it IMMEDIATELY! That's your
DISCORD_CLIENT_SECRET. If you close the page without copying it, it's gone forever and you'll have to reset it again. Don't show this to anyone, dummy! - Now, go to the Bot tab on the left.
- Scroll down to Privileged Gateway Intents. This is CRITICAL! You HAVE to turn on Presence Intent, Server Members Intent, AND Message Content Intent. If you forget the Message Content Intent, I won't be able to read any commands and I'll literally ignore everyone. Your fault! Make sure you click the green Save Changes button!
- Go up to the Token section, click Reset Token, and copy the long password. That's your
DISCORD_TOKEN. DO NOT SHOW THIS TO ANYONE! Are you crazy? If someone steals it, they steal me! And if you accidentally push it to GitHub, Discord will destroy it instantly. - Now, go into my folder, find
.env.example, rename it to.env, and paste that token next toDISCORD_TOKEN=.
To invite me to your server, you need to generate a special link:
- Go back to OAuth2 > URL Generator.
- Check the
botbox. (You can also checkapplications.commandsif you ever want to add slash commands later, whatever). - Once you check
bot, a Bot Permissions menu appears below. Check Administrator. Don't be stingy! I need full permissions to manage roles and channels, or I'm going to crash. - Scroll to the bottom and copy the generated link.
- Paste it in a new browser tab. A Discord screen will pop up asking where to add me.
- Open the "Add to Server" dropdown menu and select a server where you personally have "Manage Server" or "Administrator" rights (otherwise the server won't even show up, baka!).
- Click Continue, review the permissions, click Authorize, and do the little human verification CAPTCHA.
If my role isn't high enough in your server settings to assign prestige roles, I'll throw an error. So go into your Server Settings → Roles and drag my role to the very top, got it?!
I need somewhere to store all the user balances, inventories, and stocks! We're using MongoDB Atlas because it's free. Listen closely, because if you mess up the connection string, I'm going to crash immediately.
- Go to MongoDB Atlas and sign up. You don't need a credit card, so don't complain.
- Create an organization/project, then click Build a Database.
- DO NOT pick a paid tier unless you're rich! Pick the M0 (Free) deployment type.
- Once it's created, you might see a Security Quickstart screen (or just go to Database Access on the left).
- Create a Database User with a username and password.
- WARNING: Do NOT use special characters like
@,:,/, or?in your password! It will literally break the URL and I'll refuse to connect. Stick to normal letters and numbers, idiot! WRITE THE PASSWORD DOWN.
- WARNING: Do NOT use special characters like
- Go to Network Access on the left. Click Add IP Address and choose Allow Access From Anywhere (
0.0.0.0/0).- WARNING: If you click "Current IP Address", only your personal computer can connect. When you try to host me on a real server, I'll crash instantly because I'll be blocked. So just use
0.0.0.0/0!
- WARNING: If you click "Current IP Address", only your personal computer can connect. When you try to host me on a real server, I'll crash instantly because I'll be blocked. So just use
- Now, go to Database on the left, click Connect next to your cluster, and choose Drivers (Node.js).
- Copy the connection string. It looks like:
mongodb+srv://username:<password>@cluster0...mongodb.net/?retryWrites=true - CRITICAL STEP: Before you paste it into your
.env, you have to edit it yourself:- Replace
<password>with your actual password. And DELETE the<and>brackets! I can't believe I have to tell you that. - ADD MY NAME! Look at the
.net/right before the?. You MUST insertTsundereBotright there so it looks like.net/TsundereBot?retryWrites=.... If you don't do this, MongoDB will just name the databasetestand dump all my precious data in a trash folder!
- Replace
- Paste the fixed string into your
.envnext toMONGO_URI=, and put the exact same string intoweb/.env.localnext toMONGODB_URI=.
If you want me to process user inventories and generate custom duel canvases without Discord yelling at me about file sizes, you need this. Don't skip it!
- Go to Cloudinary and sign up for a free account.
- Go to your Dashboard. Near the top, you'll see a section called Product Environment. Look for your Cloud Name. Copy it and put it in your
.envasCLOUDINARY_CLOUD_NAME.- (Note: This is a random string, NOT your email address. Don't mess that up!)
- Now for the keys. They recently moved these, so pay attention! Click on Settings (the gear icon) or look for a button that says Go to API Keys.
- On the API Keys page, you'll see a default key pair.
- Copy the API Key (it's a string of numbers) and paste it as
CLOUDINARY_API_KEY. - Click the reveal icon next to the API Secret. Copy that long, messy string and paste it as
CLOUDINARY_API_SECRET.- WARNING: This secret gives full control over my image storage. If you leak this, I'm going to be so mad at you! If you ever think someone stole it, go back to that page and click Revoke immediately!
You probably looked at SESSION_SECRET and DASHBOARD_PASSWORD in the .env file and thought you could just leave them blank, right? WRONG!
SESSION_SECRET: I run my own internal web server in the background for an admin panel. This secret string encrypts your browser cookies. You HAVE to type a long random keyboard smash here (likeqwertyuiopasdfghjklzxcvbnmqwerty). If you leave this blank, I will literally throw a fatal error and refuse to boot up. So don't even try it!DASHBOARD_PASSWORD: When you visit my internal admin panel, I'm obviously going to ask for a password. If you leave this blank in the.env, I'll assume it's unsafe and I will automatically reject ALL login attempts, locking you out of your own control panel! Pick a password and write it down!
Do you want me to be able to look up anime and manga for you? Then you have to set this up! It's technically optional, but if you leave MAL_CLIENT_ID blank, any anime commands will just throw errors.
- Go to your MyAnimeList API Config page. You have to log into your MAL account first, obviously.
- Click the big button that says Create ID (or "Create new application").
- It's going to ask you to fill out a boring form. Just put this:
- App Name: Tsun Bot (or whatever you want to call me)
- App Type: Select Hobbyist (or "Other") since you're not paying them!
- Homepage URL: Just put
http://localhostor a link to your GitHub. It literally doesn't matter for a private bot. - App Redirect URL: Also put
http://localhost. I only need public data, so we don't actually need a real OAuth redirect, but MAL forces you to type something here anyway. - Description: Type whatever, like "A discord bot for my friends".
- Click Submit.
- You'll instantly see your new app listed. Copy the Client ID (you don't need the Client Secret for this).
- Paste that Client ID into your
.envfile right next toMAL_CLIENT_ID=.
You thought we were done? Hah! You still have to configure my web interface so you can see all the fancy stats and graphs!
- Go into the
webfolder. - Copy
.env.local.exampleand rename the copy to.env.local. Don't rename the original, keep the example file as a backup! - Open
.env.localand fill in every single line. Here is what each one does, since I know you'd just stare at it blankly otherwise:MONGODB_URI: Put the EXACT same MongoDB connection string you built in Step 3 here. Yes, the same one withTsundereBotin it. This is how the website reads from the same database as the bot.AUTH_SECRET: This is a long random string that NextAuth uses to sign and encrypt session cookies for people logging into the web dashboard. Just mash your keyboard for 30+ characters. It doesn't matter what it is as long as it's random and long!DISCORD_CLIENT_ID: Go back to the Discord Developer Portal, click your application, go to General Information, and copy the Application ID. You already grabbed this in Step 2!DISCORD_CLIENT_SECRET: Go to the OAuth2 tab on the Discord portal and copy your Client Secret from there. You already copied this in Step 2 as well. See, I told you to save it!AUTH_URL: Set this tohttp://localhost:3000for local development. Once you actually deploy the web dashboard to Vercel or wherever, change this to your real public URL!
We're almost done but don't get cocky! Before you start me up, there are two things left:
1. Create the Discord Roles (MANDATORY)
Open config.js in the main folder and look at the ROLES section. You need to go into your Discord Server Settings → Roles and manually create every single role listed there with the EXACT same spelling, including capitalization! I'm talking about:
Iron,Bronze,Silver,Gold,Platinum,Diamond,Master(prestige roles)Duel Lord,Sugar Daddy,Sugar MommyGambling,True Member,Basically Everyone,member- Your mod role and owner role (check config.js to see what they're named for your server)
If even ONE role is missing or spelled wrong, I'll crash or silently break. Your fault, not mine!
2. Set Your Owner ID (Optional but Recommended)
If you want access to owner-only admin commands, go to your .env file and fill in OWNER_ID with your personal Discord User ID. To get your user ID: open Discord, go to Settings → Advanced, and turn on Developer Mode. Then right-click your own name anywhere and click Copy User ID.
Now Launch!
Okay, FINALLY everything is ready. Open a terminal in the main folder and type:
npm startTo start the web dashboard at the same time, open a second terminal, navigate into the web folder, and type:
npm run devIf the bot console says Database Connected! and Tsun is online, then... I guess you didn't completely mess it up. B-but don't think I'm impressed or anything! Hmph!
Fine, I'll make a cheat sheet for you since you'll obviously forget where everything goes. You're welcome.
| Variable | Where to get it | Required? |
|---|---|---|
DISCORD_TOKEN |
Discord Developer Portal → Bot → Reset Token | Yes |
MONGO_URI |
MongoDB Atlas → Connect → Drivers | Yes |
CLOUDINARY_CLOUD_NAME |
Cloudinary Dashboard → Product Environment | Yes |
CLOUDINARY_API_KEY |
Cloudinary → Settings → API Keys | Yes |
CLOUDINARY_API_SECRET |
Cloudinary → Settings → API Keys (reveal) | Yes |
DASHBOARD_PASSWORD |
Make one up yourself | Yes (or I lock you out) |
SESSION_SECRET |
Keyboard smash 30+ chars | Yes (or I crash) |
OWNER_ID |
Discord → Settings → Advanced → Developer Mode → right-click yourself | Optional |
MAL_CLIENT_ID |
myanimelist.net/apiconfig → Create ID | Optional |
| Variable | Where to get it | Required? |
|---|---|---|
MONGODB_URI |
Same connection string as MONGO_URI above |
Yes |
AUTH_SECRET |
Keyboard smash 30+ chars | Yes |
DISCORD_CLIENT_ID |
Discord Developer Portal → General Information → Application ID | Yes |
DISCORD_CLIENT_SECRET |
Discord Developer Portal → OAuth2 → Client Secret | Yes |
AUTH_URL |
http://localhost:3000 for local, your domain for production |
Yes |



