{"record":{"id":"e1d5b273a27f9053","repo":"discordjs/discord.js","slug":"invalidmissingscopes","errorCode":"InvalidMissingScopes","errorMessage":"At least one valid scope must be provided for the invite","messagePattern":"At least one valid scope must be provided for the invite","errorType":"error_code","errorClass":"DiscordjsTypeError","httpStatus":null,"severity":"error","filePath":"packages/discord.js/src/client/Client.js","lineNumber":742,"sourceCode":"   * console.log(`Generated application invite link: ${link}`);\n   * @example\n   * const link = client.generateInvite({\n   *   permissions: [\n   *     PermissionFlagsBits.SendMessages,\n   *     PermissionFlagsBits.ManageGuild,\n   *     PermissionFlagsBits.MentionEveryone,\n   *   ],\n   *   scopes: [OAuth2Scopes.Bot],\n   * });\n   * console.log(`Generated bot invite link: ${link}`);\n   */\n  generateInvite(options = {}) {\n    if (typeof options !== 'object') throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);\n    if (!this.application) throw new DiscordjsError(ErrorCodes.ClientNotReady, 'generate an invite link');\n\n    const { scopes } = options;\n    if (scopes === undefined) {\n      throw new DiscordjsTypeError(ErrorCodes.InvalidMissingScopes);\n    }\n\n    if (!Array.isArray(scopes)) {\n      throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'scopes', 'Array of Invite Scopes', true);\n    }\n\n    if (!scopes.some(scope => [OAuth2Scopes.Bot, OAuth2Scopes.ApplicationsCommands].includes(scope))) {\n      throw new DiscordjsTypeError(ErrorCodes.InvalidMissingScopes);\n    }\n\n    if (!scopes.includes(OAuth2Scopes.Bot) && options.permissions) {\n      throw new DiscordjsTypeError(ErrorCodes.InvalidScopesWithPermissions);\n    }\n\n    const validScopes = Object.values(OAuth2Scopes);\n    const invalidScope = scopes.find(scope => !validScopes.includes(scope));\n    if (invalidScope) {\n      throw new DiscordjsTypeError(ErrorCodes.InvalidElement, 'Array', 'scopes', invalidScope);","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/discordjs/discord.js/blob/a81ed8a306d37fdc746e26a634b6a42164ba2c8c/packages/discord.js/src/client/Client.js#L724-L760","documentation":"DiscordjsTypeError with code InvalidMissingScopes is thrown when options.scopes is undefined in generateInvite(). Scopes are mandatory because the OAuth2 authorization URL is meaningless without at least one scope; the library requires them explicitly rather than guessing.","triggerScenarios":"Calling client.generateInvite() with an options object that omits the scopes key, e.g. client.generateInvite({ permissions: [...] }).","commonSituations":"Building options dynamically and the scopes property name is misspelled (scope instead of scopes); copying old v12 examples where scopes were not part of the options object.","solutions":["Always include scopes: [OAuth2Scopes.Bot] (plus others as needed) in the options object","Check for a typo: the key must be exactly 'scopes' (plural)","Import OAuth2Scopes from discord.js and use its enum values"],"exampleFix":"// before\nconst link = client.generateInvite({ permissions: ['ADMINISTRATOR'] });\n// after\nconst { OAuth2Scopes } = require('discord.js');\nconst link = client.generateInvite({ scopes: [OAuth2Scopes.Bot], permissions: ['ADMINISTRATOR'] });","handlingStrategy":"validation","validationCode":"if (!Array.isArray(opts?.scopes) || opts.scopes.length === 0) {\n  throw new Error('generateInvite requires scopes: [OAuth2Scopes.Bot]');\n}","typeGuard":"const hasScopes = (opts) => Array.isArray(opts?.scopes) && opts.scopes.length > 0;","tryCatchPattern":"try {\n  const link = client.generateInvite(opts);\n} catch (err) {\n  if (err.code === 'InvalidMissingScopes') console.error('Add scopes, e.g. scopes: [OAuth2Scopes.Bot]');\n  else throw err;\n}","preventionTips":["Always include scopes in the options object, even minimal [OAuth2Scopes.Bot]","Use the OAuth2Scopes enum, never raw strings","Double-check property name is 'scopes' (plural)"],"tags":["discord-js","oauth2","missing-parameter","invite-generation"],"backgroundTag":"missing-required-parameter","analyzedSha":"a81ed8a306d37fdc746e26a634b6a42164ba2c8c","analyzedAt":"2026-08-30T04:07:22.193Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}