diff --git a/src/helpers/interactions/commands/upsertApplicationCommands.ts b/src/helpers/interactions/commands/upsertApplicationCommands.ts index 362a62426..7488e1015 100644 --- a/src/helpers/interactions/commands/upsertApplicationCommands.ts +++ b/src/helpers/interactions/commands/upsertApplicationCommands.ts @@ -3,6 +3,7 @@ import type { EditGlobalApplicationCommand } from "../../../types/interactions/c import type { MakeRequired } from "../../../types/util.ts"; import type { Bot } from "../../../bot.ts"; import { Collection } from "../../../util/collection.ts"; +import { ApplicationCommandOption } from "../../../types/interactions/commands/applicationCommandOption.ts"; /** * Bulk edit existing application commands. If a command does not exist, it will create it. @@ -20,7 +21,13 @@ export async function upsertApplicationCommands( guildId ? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId) : bot.constants.endpoints.COMMANDS(bot.applicationId), - options + options.map((option) => ({ + name: option.name, + description: option.description, + type: option.type, + options: option.options?.map((opt) => optionToSnakeCase(opt)), + default_permission: option.defaultPermission, + })) ); return new Collection( @@ -30,3 +37,21 @@ export async function upsertApplicationCommands( }) ); } + +function optionToSnakeCase(option: ApplicationCommandOption): Record { + return { + type: option.type, + name: option.name, + description: option.description, + required: option.required, + choices: option.choices?.map((choice) => ({ + name: choice.name, + value: choice.value, + })), + options: option.options?.map((o) => optionToSnakeCase(o)), + autocomplete: option.autocomplete, + channel_types: option.channelTypes, + min_value: option.minValue, + max_value: option.maxValue, + }; +}