discordjs/discord.js · critical · DiscordjsTypeError
ClientMissingIntents
ClientMissingIntents
Error message
Valid intents must be provided for the Client.
What it means
DiscordjsTypeError with code ClientMissingIntents is thrown during Client construction (via _validateOptions) when neither options.intents nor options.ws.intents is defined. Since discord.js v13, gateway intents are mandatory — the library requires you to explicitly declare which gateway events you want, both for performance and Discord's privileged-intent policy.
Source
Thrown at packages/discord.js/src/client/Client.js:824
*
* @param {string} script Script to eval
* @returns {*}
* @private
*/
_eval(script) {
// eslint-disable-next-line no-eval
return eval(script);
}
/**
* Validates the client options.
*
* @param {ClientOptions} [options=this.options] Options to validate
* @private
*/
_validateOptions(options = this.options) {
if (options.intents === undefined && options.ws?.intents === undefined) {
throw new DiscordjsTypeError(ErrorCodes.ClientMissingIntents);
} else {
options.intents = new IntentsBitField(options.intents ?? options.ws.intents).freeze();
}
if (typeof options.sweepers !== 'object' || options.sweepers === null) {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'sweepers', 'an object');
}
if (!Array.isArray(options.partials)) {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'partials', 'an Array');
}
if (typeof options.waitGuildTimeout !== 'number' || Number.isNaN(options.waitGuildTimeout)) {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'waitGuildTimeout', 'a number');
}
if (typeof options.failIfNotExists !== 'boolean') {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'failIfNotExists', 'a boolean');View on GitHub (pinned to a81ed8a306)
Solutions
- Pass an intents array in ClientOptions: new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] })
- Add the intents key to whatever config object is spread into the Client constructor
- If you intentionally use the legacy ws shape, set options.ws.intents instead — but prefer the modern intents option
- Review the intents you need and request privileged ones (GuildMembers, MessageContent, GuildPresences) explicitly, enabling them in the Developer Portal
Example fix
// before
const client = new Client({ token });
// after
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
token,
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
}); Defensive patterns
Strategy: validation
Validate before calling
if (!clientOptions.intents && !clientOptions.ws?.intents) {
throw new Error('ClientOptions.intents is required, e.g. [GatewayIntentBits.Guilds]');
} Type guard
const hasIntents = (opts) => Array.isArray(opts?.intents) || typeof opts?.intents === 'number' || opts?.ws?.intents !== undefined;
Try / catch
try {
const client = new Client(options);
} catch (err) {
if (err.code === 'ClientMissingIntents') {
console.error('Provide intents, e.g. intents: [GatewayIntentBits.Guilds]');
} else throw err;
} Prevention
- Always define intents in ClientOptions when creating the client
- Keep intents in your config file and validate it at startup
- When migrating from v12, add the mandatory intents option
- List only needed intents; enable privileged intents in the Developer Portal if used
When it happens
Trigger: new Client({}) or new Client({ token }) without an intents property; constructing the client with options loaded from a config file missing the intents key; code migrated from discord.js v12 where intents were optional.
Common situations: Upgrading from v12 to v13+ where the required intents option did not exist before; a config loader returning an object that drops the intents field; copying an old tutorial's constructor.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- Package ${packageName} not releaseable
- The --tag option can only be used with --dev
- ClientNotReady
- InvalidMissingScopes
- InvalidScopesWithPermissions
AI-assisted analysis of discordjs/discord.js@a81ed8a306 (2026-08-30).
Data as JSON: /api/errors/c70500f36e3b3687.
Report an issue: GitHub.