mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
more fixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
||||
import type { CreateGlobalApplicationCommand } from "../../../types/interactions/commands/create_global_application_command.ts";
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import { ApplicationCommandOption } from "../../../types/interactions/commands/application_command_option.ts";
|
||||
|
||||
/**
|
||||
* There are two kinds of Slash Commands: global commands and guild commands. Global commands are available for every guild that adds your app; guild commands are specific to the guild you specify when making them. Command names are unique per application within each scope (global and guild). That means:
|
||||
@@ -22,6 +23,24 @@ export async function createSlashCommand(bot: Bot, options: CreateGlobalApplicat
|
||||
guildId
|
||||
? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId)
|
||||
: bot.constants.endpoints.COMMANDS(bot.applicationId),
|
||||
options
|
||||
{
|
||||
name: options.name,
|
||||
description: options.description,
|
||||
type: options.type,
|
||||
options: options.options ? makeOptionsForCommand(options.options) : undefined,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// @ts-ignore TODO: see if we can make this not circular
|
||||
export function makeOptionsForCommand(options: ApplicationCommandOption[]) {
|
||||
return options.map((option) => ({
|
||||
type: option.type,
|
||||
name: option.name,
|
||||
description: option.description,
|
||||
required: option.required,
|
||||
choices: option.choices,
|
||||
options: option.options ? makeOptionsForCommand(option.options) : undefined,
|
||||
channel_types: option.channelTypes,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
||||
import type { EditGlobalApplicationCommand } from "../../../types/interactions/commands/edit_global_application_command.ts";
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import { makeOptionsForCommand } from "./create_slash_command.ts";
|
||||
|
||||
/**
|
||||
* Edit an existing slash command. If this command did not exist, it will create it.
|
||||
@@ -19,6 +20,11 @@ export async function upsertSlashCommand(
|
||||
guildId
|
||||
? bot.constants.endpoints.COMMANDS_GUILD_ID(bot.applicationId, guildId, commandId)
|
||||
: bot.constants.endpoints.COMMANDS_ID(bot.applicationId, commandId),
|
||||
options
|
||||
{
|
||||
name: options.name,
|
||||
description: options.description,
|
||||
type: options.type,
|
||||
options: options.options ? makeOptionsForCommand(options.options) : undefined,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user