mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 08:50:07 +00:00
fix: slash upsert bugs
This commit is contained in:
@@ -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<string, any> {
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user