{"record":{"id":"6bf8868fe3933956","repo":"discordjs/discord.js","slug":"commandinteractionoptionnosubcommandgroup","errorCode":"CommandInteractionOptionNoSubcommandGroup","errorMessage":"CommandInteractionOptionNoSubcommandGroup","messagePattern":"CommandInteractionOptionNoSubcommandGroup","errorType":"error_code","errorClass":"DiscordjsTypeError","httpStatus":null,"severity":"error","filePath":"packages/discord.js/src/structures/CommandInteractionOptionResolver.js","lineNumber":140,"sourceCode":"   * @returns {?string} The name of the selected subcommand, or null if not set and not required.\n   */\n  getSubcommand(required = true) {\n    if (required && !this._subcommand) {\n      throw new DiscordjsTypeError(ErrorCodes.CommandInteractionOptionNoSubcommand);\n    }\n\n    return this._subcommand;\n  }\n\n  /**\n   * Gets the selected subcommand group.\n   *\n   * @param {boolean} [required=false] Whether to throw an error if there is no subcommand group.\n   * @returns {?string} The name of the selected subcommand group, or null if not set and not required.\n   */\n  getSubcommandGroup(required = false) {\n    if (required && !this._group) {\n      throw new DiscordjsTypeError(ErrorCodes.CommandInteractionOptionNoSubcommandGroup);\n    }\n\n    return this._group;\n  }\n\n  /**\n   * Gets a boolean option.\n   *\n   * @param {string} name The name of the option.\n   * @param {boolean} [required=false] Whether to throw an error if the option is not found.\n   * @returns {?boolean} The value of the option, or null if not set and not required.\n   */\n  getBoolean(name, required = false) {\n    const option = this._getTypedOption(name, [ApplicationCommandOptionType.Boolean], ['value'], required);\n    return option?.value ?? null;\n  }\n\n  /**","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/discordjs/discord.js/blob/a81ed8a306d37fdc746e26a634b6a42164ba2c8c/packages/discord.js/src/structures/CommandInteractionOptionResolver.js#L122-L158","documentation":"CommandInteractionOptionNoSubcommandGroup is thrown by getSubcommandGroup when `required` (default false) is passed as true and no subcommand group was selected. The interaction simply did not resolve through a subcommand group, which is normal for commands without groups or when the user picked a direct subcommand.","triggerScenarios":"Calling interaction.options.getSubcommandGroup(true) when the user invoked a direct subcommand (no group) or the command has no subcommand groups; misordering lookups when the resolved option chain stops at a plain subcommand.","commonSituations":"Shared command dispatcher that always queries the group; commands where groups were added later and old client-side caches still send old structures; calling getSubcommandGroup(true) defensively without realizing required defaults to false and forces the throw.","solutions":["Only pass true when your command schema guarantees a group at that level; otherwise call getSubcommandGroup() (default false) and null-check","Branch on getSubcommandGroup() first: if non-null, then call getSubcommand(); else treat as direct subcommand","Verify the deployed command registration actually includes subcommand groups"],"exampleFix":"// before\nconst group = interaction.options.getSubcommandGroup(true); // throws for direct subcommands\n// after\nconst group = interaction.options.getSubcommandGroup();\nconst sub = interaction.options.getSubcommand(false);","handlingStrategy":"validation","validationCode":"const group = interaction.options.getSubcommandGroup();\nif (group === null) { /* direct subcommand path */ }","typeGuard":"function hasSubcommandGroup(interaction) {\n  return interaction.options.data.some(o => o.type === ApplicationCommandOptionType.SubcommandGroup);\n}","tryCatchPattern":"try {\n  const group = interaction.options.getSubcommandGroup(true);\n} catch (err) {\n  if (err.code === 'CommandInteractionOptionNoSubcommandGroup') {\n    // fall through to direct subcommand handling\n  } else throw err;\n}","preventionTips":["Remember required defaults to false here — pass true only when the schema guarantees a group","Dispatch on group presence before resolving the subcommand","Keep command schema docs in sync with the actual registration"],"tags":["discord-js","slash-commands","subcommand-group"],"backgroundTag":"missing-subcommand","analyzedSha":"a81ed8a306d37fdc746e26a634b6a42164ba2c8c","analyzedAt":"2026-08-30T04:07:22.193Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}