PROMO Get 10% off any server with code: START Limited-time offer

Discord bot β€” Node.js

Discord.js on Node.js 20 LTS with the PM2 process manager, which automatically brings your bot back up after a crash.

Deployment

  1. Upload your filesUpload the project without the node_modules folder β€” dependencies are installed from package.json.
  2. Set the start fileIn the β€œStartup” tab, point to your main file, e.g. index.js.
  3. Add the token in .envNever put the token directly in your code.
  4. Start itYou'll see the bot's logs live in the console.
.env
DISCORD_TOKEN=your_bot_token
GUILD_ID=123456789012345678
index.js
require('dotenv').config();
const { Client, GatewayIntentBits } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.once('ready', () => console.log(`Logged in as ${client.user.tag}`));
client.login(process.env.DISCORD_TOKEN);
πŸ”„

PM2 auto-restartIf the bot throws an unhandled exception, PM2 restarts it in a fraction of a second. You'll find the cause in the console logs.