Serveurs de jeux gratuits pour Minecraft, Terraria, CS & Discord · Sans carte bancaire !
Discord Bots7 min•November 6, 2026

How to Host a Discord.js v14 Bot 24/7 with Node.js 22 LTS: Production Guide

Complete guide to developing and deploying a Discord.js v14 bot: Slash commands registration, GatewayIntentBits configuration, PM2 supervisor, and 24/7 free cloud hosting on CoalByte.

CoalByte Developer Relations
CoalByte Developer Relations
Lead Node.js Architect
How to Host a Discord.js v14 Bot 24/7 with Node.js 22 LTS: Production Guide

#Modern Discord Bot Architecture with Discord.js v14

Discord.js version 14 is built natively on modern Node.js standards, utilizing ECMAScript modules, the REST API v10, and typed Gateway Intents. If you are building a moderation bot, music bot, or community economy system, hosting your bot on a reliable 24/7 cloud container is required to keep your users engaged.

In this guide, you will learn how to write a production-ready Discord.js v14 bot and deploy it permanently to CoalByte 100% Free Discord Bot Hosting.


1. Initializing Your Project with Node.js 22 LTS

Create a clean directory and initialize your package.json:

bash
mkdir my-discord-bot && cd my-discord-bot
npm init -y
npm install discord.js dotenv

Ensure your package.json specifies "type": "module" to unlock native ES imports:

json
{
  "name": "my-discord-bot",
  "version": "1.0.0",
  "type": "module",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "discord.js": "^14.16.3",
    "dotenv": "^16.4.5"
  }
}

2. Client Initialization & Gateway Intents

In Discord API v10, bots must explicitly declare the data events they listen to. In index.js:

javascript
import { Client, GatewayIntentBits, Events } from 'discord.js';
import dotenv from 'dotenv';
dotenv.config();

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

client.once(Events.ClientReady, (readyClient) => {
  console.log(`✅ Logged in and online as ${readyClient.user.tag}!`);
  readyClient.user.setActivity('Hosted 24/7 on CoalByte Cloud');
});

client.on(Events.InteractionCreate, async (interaction) => {
  if (!interaction.isChatInputCommand()) return;

  if (interaction.commandName === 'ping') {
    const latency = client.ws.ping;
    await interaction.reply({
      content: `🏓 Pong! WebSocket gateway latency is **${latency}ms**.`,
      ephemeral: true
    });
  }
});

client.login(process.env.DISCORD_TOKEN);

3. Registering Slash Commands (Application Commands)

Register your slash commands globally or to your test guild using the Discord REST client:

javascript
import { REST, Routes, SlashCommandBuilder } from 'discord.js';
import dotenv from 'dotenv';
dotenv.config();

const commands = [
  new SlashCommandBuilder()
    .setName('ping')
    .setDescription('Replies with WebSocket heartbeat latency'),
  new SlashCommandBuilder()
    .setName('serverinfo')
    .setDescription('Displays current server stats and members')
].map(command => command.toJSON());

const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN);

try {
  console.log('Refreshing application (/) commands...');
  await rest.put(
    Routes.applicationCommands(process.env.CLIENT_ID),
    { body: commands }
  );
  console.log('Successfully reloaded application (/) commands.');
} catch (error) {
  console.error(error);
}

4. Deploying 24/7 on CoalByte Free Tier

Deploying to CoalByte takes less than 60 seconds without requiring a credit card:

  1. Open your CoalByte Free Discord Bot Hosting portal and navigate to Dashboard.
  2. Click Create Server and choose the Node.js (Discord.js) container.
  3. Use the web File Manager or connect via SFTP to upload your files (package.json, index.js).
  4. In the container settings, add your secure environment variables:
env
   DISCORD_TOKEN=your_bot_token_here
   CLIENT_ID=your_application_id
  1. Click Start in the live web console.

CoalByte automatically runs npm install, starts your bot using an internal process supervisor, and monitors health around the clock with automated sub-second crash recovery!

Tags :#Discord.js#Node.js#Discord Bots#JavaScript#Slash Commands#24/7#Hosting
⚡ 100% Free · No Credit Card Required

Ready for 24/7 high-performance free hosting?

Launch your dedicated server with 3 GB RAM, 2 vCPU, 8 GB fast SSD, and Anycast Anti-DDoS in under 60 seconds.

Deploy Free Server
Tous les Articles