discord.js bot refuses to start: missing or disallowed intents
CLIENT_MISSING_INTENTSShort answer
discord.js will not log in without an intents list on the Client. Pass intents as an array of GatewayIntentBits values. If the bot then closes with a disallowed intents error, a privileged intent (Message Content, Server Members or Presences) is used in code but not switched on in the Developer Portal.
Fix it fast
1Find out which cause you have
Print the discord.js version and look at how the Client is created. The version decides which intents syntax is valid.
npm ls discord.js grep -n "new Client" -A 4 index.js2Match what you see, then jump to its fix
- 1
CLIENT_MISSING_INTENTS at startup, before the bot connectsThe Client is created without an intents optionFix - 2
Intents.FLAGS is still in the code after upgrading discord.jsCode still uses the old v13 Intents.FLAGS syntaxFix - 3
[DisallowedIntents] at login; Discord closes the gateway connection with code 4014A privileged intent is used in code but not enabled in the Developer PortalFix
- 1
What does the error look like?
CLIENT_MISSING_INTENTS[DisallowedIntents]Intents.FLAGS
Cause 1 of 3
The Client is created without an intents option
1Check
Look at the new Client call. A call with no options, or with an empty intents array, is what the guide says makes discord.js throw.
grep -rn "new Client(" --include=*.js .2Fix
Pass the intents your bot actually uses. Guilds is the usual minimum; add GuildMessages for message events.
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
});3Verify
Start the bot again. It should reach the ready event instead of throwing.
node index.jsConfirmed by discordjs.guide
Cause 2 of 3
Code still uses the old v13 Intents.FLAGS syntax
1Check
In v14 the Intents class became IntentsBitField and Intents.FLAGS was replaced by the GatewayIntentBits enum. Search for the old names.
grep -rn "Intents.FLAGS" --include=*.js .2Fix
Replace each Intents.FLAGS.X with GatewayIntentBits.X, and Partials strings with the Partials enum.
// v13
const client = new Client({ intents: [Intents.FLAGS.GUILDS], partials: ['CHANNEL'] });
// v14
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds], partials: [Partials.Channel] });3Verify
Run npm ls discord.js to confirm v14, then start the bot.
npm ls discord.js
node index.jsConfirmed by discordjs.guide
Cause 3 of 3
A privileged intent is used in code but not enabled in the Developer Portal
1Check
The privileged intents are GuildPresences, GuildMembers and MessageContent. See if any of them appears in your intents array.
grep -rn "GuildPresences\|GuildMembers\|MessageContent" --include=*.js .2Fix
In the Developer Portal open your application, go to the Bot page and switch on the matching toggle under Privileged Gateway Intents, save, then restart the bot. If you do not need the intent, remove it from the array instead.
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent, // needs the Message Content toggle on the Bot page
],
});3Verify
Restart the bot. The login now completes and message.content has text.
node index.jsConfirmed by docs.discord.com
How do I stop it coming back?
- List only the intents the bot uses; each privileged one needs a switch in the portal and, for large bots, approval.
- Pin the major version of discord.js in package.json so an upgrade does not change the intents syntax under you.
- Read the upgrade guide before moving from v13 to v14.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fixBack end
The command npm run build -- --prod exited with code 1 (Angular)
The command "npm run build -- --prod" exited with code 1
Exit code 1 only says the build failed; the real message is above it.
2 causes, each with a fix