How to Deploy a discord.js Bot on Pterodactyl Panel
To deploy a
discord.js(Node.js) bot on VisiHost's Pterodactyl panel: (1) Upload your project files via SFTP or Web File Manager, (2) Configure yourBOT_TOKENin the Startup Environment variables, (3) Install packages vianpm installin the Web Console, and (4) Click Start to launch your persistent 24/7 process.
Prerequisites
Before starting deployment, ensure you have:
- An active VisiHost Free Bot Hosting or Paid Discord Bot Hosting container.
- Your Discord Bot Token from the Discord Developer Portal.
- Node.js version specified in your
package.json(VisiHost containers support Node.js 18, 20, and 22).
Step-by-Step Deployment Instructions
Step 1: Prepare Your Local Project Files
Ensure your project contains a valid package.json file specifying your startup entry file (e.g., index.js, main.js, or bot.js).
Example package.json:
{
"name": "my-discord-bot",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"discord.js": "^14.14.0",
"dotenv": "^16.4.0"
}
}
Important: Do NOT upload the
node_modulesfolder. Node dependencies will be automatically compiled and installed directly inside the Linux container for optimal performance.
Step 2: Upload Files via Web File Manager or SFTP
- Log into your Pterodactyl Control Dashboard at
free.visihost.inorpaid.visihost.in. - Select your Bot Container server.
- Click on the Files tab on the left navigation bar.
- Drag and drop your project files (e.g.,
index.js,package.json,.env.example, subfolders).
Alternatively, connect via SFTP using credentials found in the Settings tab with clients like FileZilla or WinSCP.
Step 3: Configure Startup Command & Environment Variables
- Navigate to the Startup tab in your container dashboard.
- Verify the JS File setting matches your entry file (default:
index.js). - Under Environment Variables, enter your secret
BOT_TOKEN:- Key:
BOT_TOKEN - Value:
MTE...your_actual_token_here...
- Key:
// Accessing token safely inside index.js:
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });
client.login(process.env.BOT_TOKEN);
Step 4: Install Dependencies & Launch
- Click on the Console tab.
- If automatic installation is enabled, packages will install on initial startup.
- To manually trigger installation, type:
npm install - Click the green Start button in the top control panel.
Troubleshooting Common discord.js Errors
1. DisallowedIntentsException / Privileged Intents Error
- Symptom: Bot crashes immediately upon login with
[DISALLOWED_INTENTS]. - Fix: Go to Discord Developer Portal ➔ your application ➔ Bot ➔ Enable Server Members Intent, Message Content Intent, and Presence Intent.
2. Native C++ Modules (better-sqlite3, canvas)
- VisiHost Linux containers include pre-installed
gcc,g++, andmaketoolchains. Native node modules compile automatically duringnpm install.
Next Steps & Related Guides
- Check Discord Bot RAM & CPU Requirements to choose the right container specs.
- Learn how to solve crashes with our Discord Bot Crash Troubleshooting Guide.
- Upgrade to zero-sleep persistent performance starting at ₹10/mo on VisiHost Discord Hosting.