SimplisticNode

Hosting a Discord bot

Keep your Discord bot online 24/7. How to prepare your code, keep your token safe, upload or deploy from GitHub, and fix a bot that will not start.

Apps5 min read

Running a bot from your own computer means it drops offline the moment you close the lid, restart for updates or lose your internet connection. Proper bot hosting keeps it up around the clock. This guide covers getting your code ready, deploying it, keeping your token safe and fixing the most common problems.

Why not just run it on my PC?

  • Your bot is only online while your computer is on and connected.
  • Home connections drop, and your IP address can change.
  • Crashes are not restarted until you notice.
  • Leaving a PC on all day costs more in electricity than you might think.

What you get with our bot hosting

  • Always-on hosting so your bot never sleeps.
  • Support for any language: Node.js (discord.js), Python (discord.py), Java, Go, Rust and more. If it runs on Linux, it runs here.
  • Automatic restart within seconds if the bot crashes.
  • Persistent storage for databases, config and files, kept between restarts.
  • A live web console to watch logs, run commands and restart your bot.
  • GitHub deploys, so pushing new code can update your bot automatically.
  • DDoS protection and a 1 Gbps uplink.

It is one simple plan, priced per bot, with no setup fees. Multi-buy discounts apply the more bots you host.

Before you upload: get your bot ready

  1. Make sure the bot runs on your own computer first. It is much easier to fix problems locally.
  2. Move your bot token out of your code and into an environment variable or a config file that you never commit to Git.
  3. List your dependencies. For Node.js that is package.json, and for Python a requirements.txt file. Dependencies should be installed from these files on the server, rather than copied over from your own computer.
  4. Know your start command, for example node index.js or python main.py.
  5. If your bot saves data, make sure it writes to a file or database inside its own folder, so it survives restarts.

Example: a discord.js bot

Read the token from the environment with process.env.DISCORD_TOKEN instead of pasting it into your code. Make sure every package you use is listed under dependencies in package.json, with a start script such as node index.js. There is usually no need to upload your node_modules folder, which is often larger than the rest of your bot put together, and packages built on your own computer may not work on Linux.

Example: a discord.py bot

Read the token with os.getenv('DISCORD_TOKEN') instead of hard-coding it. List your packages in requirements.txt, for example discord.py and any others you import, and leave your local virtual environment folder out of the upload. Your main file is whatever you would normally run with python, such as main.py or bot.py.

Getting your bot online

  1. Order a Discord bot plan. Your hosting is ready within seconds.
  2. Upload your code through the file manager, or connect your GitHub repository for automatic deploys on every push.
  3. Set your bot token and any other environment variables.
  4. Set the start command or main file for your language.
  5. Hit start and watch the console confirm the bot has logged in.
  6. Check the bot shows as online in your Discord server and responds to a command.

Keep your bot token safe

Your token is effectively your bot's password. Anyone who has it can control your bot and everything it has permission to do in every server it is in.

  • Never paste it into Discord, screenshots or support tickets.
  • Never commit it to GitHub, even in a private repository. Add your .env or config file to .gitignore.
  • If it leaks, reset it straight away in the Discord Developer Portal, then update it in your hosting.
  • Give your bot only the permissions it needs, rather than Administrator.

Using a database

For most bots, SQLite is the simplest choice. It is a single file stored alongside your code, and because storage is persistent it survives restarts and redeploys. If your bot outgrows SQLite, or you want to share data with a website, you can connect to an external database instead.

My bot will not start: common fixes

  • Invalid token or login failed: the token is wrong or has been reset. Copy a fresh one from the Discord Developer Portal.
  • Used disallowed intents: your code asks for a privileged intent, such as Message Content or Server Members, that is not switched on for your bot. Turn it on under the Bot section of the Developer Portal.
  • Cannot find module or ModuleNotFoundError: a dependency is missing from package.json or requirements.txt.
  • Wrong version: check your bot's library needs the language version the server is using, for example a recent Node.js release for discord.js.
  • Bot keeps restarting: it is crashing on start. Read the first error in the console rather than the last, as that is usually the real cause.
  • Online but not responding: check the bot has permission to read and send messages in that channel, and that slash commands have been registered.

Bot hosting or a VPS?

Bot hosting is the easy route: no server to manage, just your code, a console and automatic restarts. A VPS makes sense if you want to run a bot alongside a website, a database server and other services on one machine, and you are happy managing Linux yourself.

Growing bots

Once a bot is in a very large number of servers, Discord requires it to use sharding, splitting the connection into several pieces. Most libraries handle this for you with a sharding manager. If your bot is getting big and you are not sure what it needs, ask us.

Need help deploying? Our team knows Discord bots and will get you set up on live chat or Discord.

Still stuck?

Our team is on hand 24/7. Ask on Discord for a quick reply, or open a ticket and we'll sort it.