diff --git a/src/helpers/interactions/commands/createApplicationCommand.ts b/src/helpers/interactions/commands/createApplicationCommand.ts index 009deb707..fea31422c 100644 --- a/src/helpers/interactions/commands/createApplicationCommand.ts +++ b/src/helpers/interactions/commands/createApplicationCommand.ts @@ -42,5 +42,8 @@ export function makeOptionsForCommand(options: ApplicationCommandOption[]) { choices: option.choices, options: option.options ? makeOptionsForCommand(option.options) : undefined, channel_types: option.channelTypes, + autocomplete: option.autocomplete, + min_value: option.minValue, + max_value: option.maxValue, })); } diff --git a/src/helpers/interactions/commands/upsertApplicationCommands.ts b/src/helpers/interactions/commands/upsertApplicationCommands.ts index 7488e1015..b47f668e3 100644 --- a/src/helpers/interactions/commands/upsertApplicationCommands.ts +++ b/src/helpers/interactions/commands/upsertApplicationCommands.ts @@ -4,6 +4,7 @@ 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"; +import { makeOptionsForCommand } from "./createApplicationCommand.ts"; /** * Bulk edit existing application commands. If a command does not exist, it will create it. @@ -25,7 +26,7 @@ export async function upsertApplicationCommands( name: option.name, description: option.description, type: option.type, - options: option.options?.map((opt) => optionToSnakeCase(opt)), + options: option.options ? makeOptionsForCommand(option.options) : undefined, default_permission: option.defaultPermission, })) ); @@ -37,21 +38,3 @@ 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, - }; -}