How do I run my Discord bot?
- In the panel, open My servers and click your server.
- On the Overview tab, wait for the App row to say "Discord bot is ready". The page refreshes itself.
- Note the IP in the Connection address row.
- Create an application in the Discord Developer Portal. On the Bot page, use Reset Token to get your token.
- Connect with SSH and open the file:
nano /opt/seturack/discord/bot/.env - Paste the token after
DISCORD_TOKEN=and save. The sample bot connects by itself within seconds. - To see what it is doing:
su - app -c "pm2 logs bot --lines 20" - In the portal, open OAuth2 > URL Generator, select
botandapplications.commands, then use the link to add the bot to your Discord server. Type/pingand the bot answerspong.
Running your own code
Run su - app, then cd /opt/seturack/discord/bot. Put your code here, replacing index.js if you need to:
npm install
pm2 restart bot
pm2 save
Good to know
- With no token, the process stays up and logs "token bekleniyor / waiting for token". That is normal.
- Keep your token private. Only the bot user can read
.env. - PM2 starts the bot when the server boots. The bot takes no incoming connections, so only port 22 for SSH is open.
No server yet? Order a server with Discord botu installed: you choose the size and pay for what you choose.
Was this helpful?
Thanks for your feedback!