1. Home
  2. Guides
  3. Discord bots
Discord botsGuide

How to host a Discord bot 24/7

As long as your bot runs on your computer it is only online when you are. Hosting it on a server keeps it connected to Discord around the clock. These are the steps, using discord.js as the example.

  • 2 min read
  • 6 sections
Discord bots

In short

  • A bot on your computer is only online while you are; on a server it is online around the clock.
  • The token is the bot's password: do not push it to a repository or write it into the code.
  • Upload the files over FTP, paste the token in the panel, press Start and read the logs if something fails.

1. Create the application and get the token

In Discord's developer portal create an application, add a bot and copy its token. The token is the bot's password: whoever has it controls the bot, so do not push it to a repository or paste it in a chat.

If it leaks, generate a new one from the same portal; the old one stops working.

2. Prepare the project

Your project needs a package.json with its dependencies and a main file (for example index.js). Check that it starts on your computer with node before uploading it.

3. Pick the language and the plan

Choose your bot's language and the memory it needs. A small bot that answers commands uses little; one that keeps a lot in memory or serves many servers needs more.

4. Upload the files over FTP

Connect over FTP with the credentials from the panel and upload your project, package.json included. The panel installs the dependencies it declares.

5. Set the token and start

Paste the token in the panel instead of writing it into the code, and press Start. If your main file is not called index.js, set it in the settings.

From the panel you can read the logs, which is the first place to look if something fails.

6. Maintain it

Restart the bot from the panel when you upload changes and watch the logs after each update. If you switch language later, remember the previous code is deleted: keep a copy on your computer.