Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

discord.js bot refuses to start: missing or disallowed intents

ErrorCLIENT_MISSING_INTENTS

Short 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.

  • Applies to discord.js 14, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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.js
  2. 2Match what you see, then jump to its fix

    1. 1CLIENT_MISSING_INTENTS at startup, before the bot connectsThe Client is created without an intents optionFix
    2. 2Intents.FLAGS is still in the code after upgrading discord.jsCode still uses the old v13 Intents.FLAGS syntaxFix
    3. 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

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

Confirmed by discordjs.guide

Did this fix it?

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

Confirmed by discordjs.guide

Did this fix it?

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

Confirmed by docs.discord.com

Did this fix it?

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 fix

Back 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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.