How can we help?

Search our guides and tutorials, or browse the categories below.

How do I run my Discord bot?

Apps 113 views Markdown
  1. In the panel, open My servers and click your server.
  2. On the Overview tab, wait for the App row to say "Discord bot is ready". The page refreshes itself.
  3. Note the IP in the Connection address row.
  4. Create an application in the Discord Developer Portal. On the Bot page, use Reset Token to get your token.
  5. Connect with SSH and open the file: nano /opt/seturack/discord/bot/.env
  6. Paste the token after DISCORD_TOKEN= and save. The sample bot connects by itself within seconds.
  7. To see what it is doing: su - app -c "pm2 logs bot --lines 20"
  8. In the portal, open OAuth2 > URL Generator, select bot and applications.commands, then use the link to add the bot to your Discord server. Type /ping and the bot answers pong.

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!

Still Need Help?

If you can't find what you need, get in touch.