In short
- A discord.js bot goes offline when your PC does: to keep it 24/7 it has to live on a server.
- Before uploading it, take the token out of the code and read it from an environment variable.
- On bot hosting you upload the project, the panel installs the dependencies and you start it with one button.
Why your bot goes offline
A Discord bot is a program that has to be running to connect to Discord and respond. If you run it with node on your PC, it stops when you close the terminal, put the computer to sleep or your connection drops. Discord doesn't keep it alive for you: the bot has to live on a machine that is always on.
1. Take the token out of the code
If your token is written in the code (client.login("your-token")), anyone who sees the files can control your bot. Before uploading anything, read it from an environment variable:
client.login(process.env.DISCORD_BOT_TOKEN);On bot hosting you paste the token in the panel and it reaches the bot as the DISCORD_BOT_TOKEN variable. It is stored encrypted and isn't visible over FTP. If you ever uploaded it somewhere public, regenerate it in the Discord developer portal.
2. Check your package.json
The server installs dependencies from your package.json, so everything the bot uses has to be in dependencies: discord.js and any other library. If something is only installed on your PC, it will be missing on the server.
Also set the start file. If your main file is index.js or src/index.js it is detected on its own; if it has another name, put it in the main field of package.json or in the panel settings.
3. Don't upload node_modules
The node_modules folder is huge and system-specific. You don't need to upload it: the panel installs dependencies on the server. Upload the code, package.json and package-lock.json if you have one.
4. Pick the Node.js version
discord.js needs a recent Node.js. By default the server uses Node.js 24, and in the panel settings you can choose another between 18 and 25 if your project needs it. Use the same one you have on your PC to avoid surprises.
5. Upload the project
There are two ways. Over FTP, with any client (FileZilla, for example): copy the project folder using the access details the panel gives you.
Or from GitHub: in the settings you enter your repository and the panel updates the code from there. It is the easiest if you already use git, since every change you push reaches the bot without copying files by hand.
6. Start it and check the logs
Press Start in the panel. Whatever your bot writes with console.log shows up in the panel logs: that's where you see whether it connected, or the error if something fails. When you see its ready message, try it on your Discord server.
Common mistakes
- “Used disallowed intents”: enable the privileged intents your bot uses (Message Content, for example) in the Discord developer portal.
- “Cannot find module”: that library isn't in your package.json dependencies.
- The bot starts and stops: check the end of the logs; it's almost always a code error or a badly pasted token.
- Slash commands don't respond: the commands have to be registered with Discord (once, with your command deploy script).
Free or paid?
There are free bot services, with limits on hours, restarts or resources. For a bot your community uses every day, what matters is that it doesn't go down: we compare them in the free or paid Discord bot hosting guide.
