Host a Discord Node.js bot with discord.js v14
npm project, intents, token, start: the steps to put a discord.js v14 bot online, one at a time.
A discord.js v14 bot is a classic Node.js project: a package.json, an entry file and a few dependencies. The useful steps are always the same: create the project, declare the intents, read the token from the environment, then check the start before handing the bot to the server.
- discord.js v14 works with Node.js 18 or newer, and the client declares its intents.
- The token is read from environment variables, never from index.js.
- Used disallowed intents and error 4014 come from the same setting: a privileged intent disabled in the portal.
Create the project
discord.js v14 works with Node.js 18 or newer. The project is made of a package.json, which lists the dependencies, and an entry file, index.js.
- npm init -y: creates the package.json with default values.
- npm install discord.js: adds discord.js v14 to the dependencies.
- In the scripts section of package.json, add "start": "node index.js" to start the bot with npm start.
Write the client
The client must declare the intents it needs. An intent missing from the code receives no events, and a privileged intent that is not enabled in the portal makes the connection fail.
- GatewayIntentBits.Guilds and GatewayIntentBits.GuildMessages: server and message events.
- GatewayIntentBits.MessageContent: a privileged intent, to enable in the developer portal to read message text.
- client.login(process.env.DISCORD_TOKEN): the token comes from the environment, never from the code.
Start and check
Test the bot locally before uploading it. A connected bot should print the confirmation you planned in its startup event.
- npm install: installs the dependencies listed in package.json.
- npm start: starts the bot with the start script.
- If the console prints Used disallowed intents, a privileged intent is disabled in the portal: enable it, then restart the bot.
Why ACLClouds for a discord.js bot
The free plan includes 1 bot, 315 MB of RAM and 715 MB of storage. Node.js, ffmpeg, yt-dlp and deno are already in the Node.js image, and files are uploaded over SFTP.
- Free plan: 1 bot, 315 MB of RAM, 0.25 vCPU, 715 MB of storage, uploads up to 100 MB.
- Node.js image: ffmpeg, yt-dlp and deno already installed.
- SFTP access per bot on port 2222, with the login details shown in the “SFTP access” card.
Frequently asked questions
Which Node.js version should I use?
For a new discord.js v14 project, aim for Node.js 18 or newer, which is still maintained. Older versions eventually cause security problems.
Should I upload the node_modules folder?
No. It is heavy, and the free storage is 715 MB. Upload package.json and package-lock.json, then let the installation rebuild the folder.
Why does the bot print Used disallowed intents?
The code requests a privileged intent, such as MessageContent, that is not enabled in the Discord developer portal. Enable it, then restart the bot.