Sign inCreate server
Apps & bots

How to Host a Discord.js Bot 24/7 (Node.js)

Host your discord.js bot 24/7: connect your Git repo, save the token as an encrypted variable, invite the bot and check it live from the SolumeCore panel.

6 min read#discord bot#discord.js#node.js bot hosting#host discord bot 24/7#alojar bot de discord#bot de discord node.js#deploy discord bot

To host a discord.js bot 24/7 on SolumeCore, put your code on a Node.js app plan, save the bot token as an encrypted variable, start the app and invite the bot to your server. The panel includes a Discord bot assistant that checks your token with Discord and builds the invite link, so the whole setup takes a few minutes and your PC can stay off.

Before you start

  • A SolumeCore app plan for Node.js. You can see the available plans on the programming page.
  • A bot project with an entry file (for example index.js) and a package.json. If you don't have one yet, the sample in step 1 works.
  • A Discord account, to create the bot application in Discord's developer portal.

Step 1: Prepare your bot code

Your code must read the token from an environment variable, never from the source file. That way the token stays out of Git and out of your files. Here is a minimal discord.js bot:

javascript
// index.js
const { Client, Events, GatewayIntentBits } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.once(Events.ClientReady, (c) => {
  console.log(`Logged in as ${c.user.tag}`);
});

client.login(process.env.DISCORD_TOKEN);

And the matching package.json, with a start script:

json
{
  "name": "my-discord-bot",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "discord.js": "^14.16.0"
  }
}
i
Note

discord.js 14 needs a recent Node.js version (18 or newer). You pick the Node.js version of your app in Code > Packages > Language version; it applies on the next restart.

Step 2: Get your code onto the app

The most reliable way is a Git repository, because you set the build and start commands explicitly and every update is one click.

  1. Open your app in the panel and go to the Code tab, then Deploy.
  2. Press Connect repository. Choose Public repository (paste the HTTPS link) or Private repository (paste the SSH link and add the read-only deploy key it shows you).
  3. On the last step, set Build command to npm install and Start command to npm start (or node index.js).
  4. Press Save and deploy.

The full walkthrough, including private repositories and automatic deploys, is in Deploy an app from GitHub or GitLab.

If you prefer not to use Git, open Files and use Upload > Upload files, or connect with SFTP, and put your project in the main folder. Without a repository, the app starts with the default command of its Node.js environment, which you can review under Settings > Startup. Dependencies listed in your package.json are installed when the app starts.

i
Note

The first start can fail with a missing-token error. That is expected: you add the token in the next step.

Step 3: Create the bot and save the token

  1. Still under Code > Deploy, scroll to Quick start and press Open assistant on the Discord bot assistant card. You can also open it from Code > Variables > Import / export > Discord bot assistant.
  2. In the first step, Create the bot, follow what the assistant shows: open the Discord Developer Portal, press New Application and give it your bot's name. On the Bot tab press Reset Token and copy the token.
  3. If your bot reads message content, turn on Message Content Intent on that same Bot tab.
  4. Paste the token into Bot token. SolumeCore stores it encrypted as the DISCORD_TOKEN variable (the same name used in the sample code). To use another name, press Saved as DISCORD_TOKEN · change and type it.
!
Warning

The token is the password of your bot. Never paste it into your code, a Git repository, a screenshot or a chat. If it leaks, press Reset Token in the portal and save the new one.

Step 4: Connect and check

The second step, Connect, shows your bot's name and ID once Discord accepts the token, and runs three checks:

Check What it means If it is not green
Discord accepted the token The token is valid Reset the token in the portal and paste the new one
Your app has the token The app was restarted after the token was saved Press Restart next to the check
Your app is running The app is on Press Start next to the check

Press Check again after each fix. If the app is stopped and you want to see why, press Open the console.

Step 5: Invite the bot to your server

  1. In the third step, Invite, pick what the bot can do: Basic, Moderation, Music or Administrator. Basic is enough for most bots.
  2. Press Invite to my server, choose your Discord server and authorize.
  3. Press Done.

Your bot should now appear online in Discord. Open Console > Live console to see your own log line, such as Logged in as ....

Update your bot

With a connected repository, push your changes and press Deploy now under Code > Deploy. You can also turn on Deploy automatically on every push so each push to your branch publishes the new version by itself. Bots restart briefly during a deploy while they reconnect to Discord.

Troubleshooting

  • The bot is offline in Discord: follow the three checks above, then read Why your Discord bot shows offline.
  • Cannot find module 'discord.js': dependencies were not installed. Set Build command to npm install and deploy again, or make sure package.json is in the main folder of the app.
  • Used disallowed intents: turn on the matching intent (for example Message Content Intent) on the Bot tab of the developer portal and restart the app.
  • Changed a variable and nothing happened: variables are read when the app starts. Press Restart to apply under Code > Variables.

FAQ

Does my Discord bot stay online when I close my browser or turn off my PC?

Yes. The bot runs on SolumeCore's servers, not on your computer. It keeps running until you stop it, and you can watch it any time from the console.

Where do I put my Discord bot token?

In the Discord bot assistant or under Code > Variables, as DISCORD_TOKEN. SolumeCore stores variables encrypted, and your code reads the value with process.env.DISCORD_TOKEN.

Which Node.js version should I use for discord.js?

Use a current version, 18 or newer for discord.js 14. Choose it under Code > Packages > Language version and restart the app.

Can I host the bot without GitHub?

Yes. Upload your files from Files or over SFTP. Git just makes updates faster, because the panel builds, starts and keeps a history of each deploy for you.

Ready to put your bot online? Take a look at the Node.js and Python app plans.

Was this article helpful?
How to Host a Discord.js Bot 24/7 (Node.js)