Beginner6 minUpdated: 2026-09-13

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.

Verified against

discord.js
v14
Node.js
20 / 22
PM2
5.x
Last checked
2026-09-13

Before you start

  • An application and bot token created in the Discord Developer Portal
  • A service running Node.js (on Clodo the runtime is picked in the panel)
  • The bot invited to your guild
On This Page
All Guides
Reading progress

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.

ARCHITECTURE FLOW
1WEBSOCKET
Discord Gateway

Establishes an encrypted WSS websocket session with Discord.

2CANLI SİNYAL
Heartbeat & ACK

Heartbeat packets sustain the connection and compute latency.

3GÖZCÜ
PM2 Supervisor

Monitors memory leaks and thread health continuously.

4OTO-KURTARMA
Crash Auto-Recovery

Crashed processes are restarted automatically, with no manual step.

5SÜREKLİ ÇALIŞIR
Always-On Bot

The bot keeps running in the background; closing your session does not stop it.

Clodo
clodo.net / panelLIVE

Clodo NVMe Cloud Server

System Normal

Clodo PM2 & Node.js Process Monitor

Track your bot's memory footprint, real-time log output, and uptime stats.

Bot Status
Online (PID: 4120)
CPU Load
%0.8 (Ultra Düşük)
RAM Usage
74 MB / 4096 MB
Uptime
48 Gün 12 Saat
Clodo Panel Automations1-CLICK READY
PM2 Real-Time LogsWeb Konsolu
Node.js v20 LTSAktif
GitHub Auto DeployTetikleniyor
Discord Error WebhookBağlı

1. Modern Discord.js v14 Starter Template#

index.js
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:

Terminal
npm install -g pm2
pm2 start index.js --name "clodo-bot"
# Sunucu yeniden basladiginda otomatik baslamasi icin:
pm2 startup
pm2 save

3. Bot Hosting Methods Compared#

Method Comparison

How to Implement This?

Clodo Discord Bot Managed Hosting

Instant Bot Runtime & Web Console

Zero Linux maintenance; Node.js and Python runtimes are pre-installed with real-time web console.

Where in Panel? Upload your code from Panel > Service detail > 'SFTP & Files', pick the Node.js version on the 'Runtime' tab, then press Start.
Step-by-step Execution:
  1. 1No OS setup required; switch between Node.js 18, 20, 22 in one click.
  2. 2Store tokens securely inside the encrypted Environment Variables vault.
  3. 3Built-in watchdog daemon detects unexpected process exits and restarts instantaneously.
  4. 4View rich colored stdout/stderr streams directly in your browser console.

Was this guide helpful?

Feedback goes straight to the team that maintains this guide.

Related Guides