{"record":{"id":"c70500f36e3b3687","repo":"discordjs/discord.js","slug":"clientmissingintents","errorCode":"ClientMissingIntents","errorMessage":"Valid intents must be provided for the Client.","messagePattern":"Valid intents must be provided for the Client\\.","errorType":"error_code","errorClass":"DiscordjsTypeError","httpStatus":null,"severity":"critical","filePath":"packages/discord.js/src/client/Client.js","lineNumber":824,"sourceCode":"   *\n   * @param {string} script Script to eval\n   * @returns {*}\n   * @private\n   */\n  _eval(script) {\n    // eslint-disable-next-line no-eval\n    return eval(script);\n  }\n\n  /**\n   * Validates the client options.\n   *\n   * @param {ClientOptions} [options=this.options] Options to validate\n   * @private\n   */\n  _validateOptions(options = this.options) {\n    if (options.intents === undefined && options.ws?.intents === undefined) {\n      throw new DiscordjsTypeError(ErrorCodes.ClientMissingIntents);\n    } else {\n      options.intents = new IntentsBitField(options.intents ?? options.ws.intents).freeze();\n    }\n\n    if (typeof options.sweepers !== 'object' || options.sweepers === null) {\n      throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'sweepers', 'an object');\n    }\n\n    if (!Array.isArray(options.partials)) {\n      throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'partials', 'an Array');\n    }\n\n    if (typeof options.waitGuildTimeout !== 'number' || Number.isNaN(options.waitGuildTimeout)) {\n      throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'waitGuildTimeout', 'a number');\n    }\n\n    if (typeof options.failIfNotExists !== 'boolean') {\n      throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'failIfNotExists', 'a boolean');","sourceCodeStart":806,"sourceCodeEnd":842,"githubUrl":"https://github.com/discordjs/discord.js/blob/a81ed8a306d37fdc746e26a634b6a42164ba2c8c/packages/discord.js/src/client/Client.js#L806-L842","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst client = new Client({ token });\n// after\nconst { Client, GatewayIntentBits } = require('discord.js');\nconst client = new Client({\n  token,\n  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],\n});","handlingStrategy":"validation","validationCode":"if (!clientOptions.intents && !clientOptions.ws?.intents) {\n  throw new Error('ClientOptions.intents is required, e.g. [GatewayIntentBits.Guilds]');\n}","typeGuard":"const hasIntents = (opts) =>\n  Array.isArray(opts?.intents) || typeof opts?.intents === 'number' || opts?.ws?.intents !== undefined;","tryCatchPattern":"try {\n  const client = new Client(options);\n} catch (err) {\n  if (err.code === 'ClientMissingIntents') {\n    console.error('Provide intents, e.g. intents: [GatewayIntentBits.Guilds]');\n  } else throw err;\n}","preventionTips":["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"],"tags":["discord-js","missing-intents","client-construction","configuration"],"backgroundTag":"missing-required-config","analyzedSha":"a81ed8a306d37fdc746e26a634b6a42164ba2c8c","analyzedAt":"2026-08-30T04:07:22.193Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}