{"version":3,"file":"options.mjs","names":[],"sources":["../../src/utils/options.ts"],"sourcesContent":["import {\n  ApplicationCommandOptionType,\n  type CommandInteractionOption,\n  type Interaction,\n} from 'discord.js'\n\n/**\n * Checks if the given option is a subcommand or subcommand group\n * @param option The option to check\n * @returns Whether the option is a subcommand or subcommand group\n */\nexport function isSubcommandOption(option: CommandInteractionOption): boolean {\n  return [\n    ApplicationCommandOptionType.Subcommand,\n    ApplicationCommandOptionType.SubcommandGroup,\n  ].includes(option.type)\n}\n\n/**\n * Recursively gets all options from the given options, including options from subcommands and subcommand groups\n * @param options The options to get\n * @returns All options\n */\nexport function getAllOptions(\n  options: readonly CommandInteractionOption[],\n): CommandInteractionOption[] {\n  return options.flatMap((option) => {\n    if (isSubcommandOption(option)) {\n      return option.options ? getAllOptions(option.options) : []\n    }\n    return option\n  })\n}\n\n/** Any interaction type with an `options` property */\nexport type InteractionWithOptions = Extract<Interaction, { options: unknown }>\n\n/**\n * Checks how many options the user specified for the interaction, excluding subcommands and subcommand groups\n * @param interaction The interaction to check\n * @returns The number of options specified\n */\nexport function getOptionCount(interaction: InteractionWithOptions): number {\n  return getAllOptions(interaction.options.data).length\n}\n"],"mappings":";;;;;;;AAWA,SAAgB,mBAAmB,QAA2C;AAC5E,QAAO,CACL,6BAA6B,YAC7B,6BAA6B,gBAC9B,CAAC,SAAS,OAAO,KAAK;;;;;;;AAQzB,SAAgB,cACd,SAC4B;AAC5B,QAAO,QAAQ,SAAS,WAAW;AACjC,MAAI,mBAAmB,OAAO,CAC5B,QAAO,OAAO,UAAU,cAAc,OAAO,QAAQ,GAAG,EAAE;AAE5D,SAAO;GACP;;;;;;;AAWJ,SAAgB,eAAe,aAA6C;AAC1E,QAAO,cAAc,YAAY,QAAQ,KAAK,CAAC"}