Developing 7/24 Discord.js v14 Bots and Managing with PM2
Step-by-step guide to building a Discord.js v14 bot, slash commands, and hosting it 24/7 using PM2 process manager.
Sur cette page
Discord Bots guides
Discord.js v14 is the modern standard for Discord bot development, enforcing Gateway Intents and Slash Commands. To keep your bot online when your PC shuts down, it must be hosted 24/7 on a cloud server.
Discord Gateway & PM2 Process Supervisor Pipeline
Persistent websocket connection architecture with sub-second crash recovery managed by PM2.
Discord Gateway
Establishes an encrypted WSS websocket session with Discord.
Heartbeat & ACK
Heartbeat packets sustain the connection and compute latency.
PM2 Supervisor
Monitors memory leaks and thread health continuously.
Crash Auto-Recovery
Crashed processes are restarted automatically, with no manual step.
Always-On Bot
The bot keeps running in the background; closing your session does not stop it.
1. Modern Discord.js v14 Starter Template#
import { Client, GatewayIntentBits } from "discord.js";
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
client.once("ready", () => {
console.log(`✅ Bot aktif: ${client.user.tag}`);
});
client.on("interactionCreate", async (interaction) => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === "ping") {
await interaction.reply({ content: "🏓 Pong!", ephemeral: true });
}
});
client.login(process.env.DISCORD_TOKEN);2. Running 24/7 with PM2 Process Manager#
PM2 is a production process manager that keeps Node.js applications alive forever, auto-restarting them on crashes:
npm install -g pm2
pm2 start index.js --name "clodo-bot"
# Sunucu yeniden basladiginda otomatik baslamasi icin:
pm2 startup
pm2 save3. Bot Hosting Methods Compared#
Comment implémenter cela ?
Clodo Discord Bot Managed Hosting
Instant Bot Runtime & Web ConsoleZero Linux maintenance; Node.js and Python runtimes are pre-installed with real-time web console.
Exécution étape par étape :
- 1No OS setup required; switch between Node.js 18, 20, 22 in one click.
- 2Store tokens securely inside the encrypted Environment Variables vault.
- 3Built-in watchdog daemon detects unexpected process exits and restarts instantaneously.
- 4View rich colored stdout/stderr streams directly in your browser console.
Ce guide vous a-t-il été utile ?
Les retours sont directement transmis à l'équipe qui maintient ce guide.
Vous n’avez pas trouvé de solution ?
Vous pouvez ouvrir une demande auprès de notre équipe d’assistance depuis le panneau.

