mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 00:40:07 +00:00
29 lines
1.3 KiB
TypeScript
29 lines
1.3 KiB
TypeScript
import type { Bot } from "../../../bot.ts";
|
|
import { DiscordApplicationCommand } from "../../../types/discord.ts";
|
|
|
|
/** Fetches the global command for the given Id. If a guildId is provided, the guild command will be fetched. */
|
|
export async function getApplicationCommand(bot: Bot, commandId: bigint, options?: GetApplicationCommand) {
|
|
const result = await bot.rest.runMethod<DiscordApplicationCommand>(
|
|
bot.rest,
|
|
"GET",
|
|
options?.guildId
|
|
? bot.constants.routes.COMMANDS_GUILD_ID(
|
|
bot.applicationId,
|
|
options.guildId,
|
|
commandId,
|
|
options?.withLocalizations,
|
|
)
|
|
: bot.constants.routes.COMMANDS_ID(bot.applicationId, commandId, options?.withLocalizations),
|
|
);
|
|
|
|
return bot.transformers.applicationCommand(bot, result);
|
|
}
|
|
|
|
/** https://discord.com/developers/docs/interactions/application-commands#endpoints-query-string-params */
|
|
export interface GetApplicationCommand {
|
|
/** Guild ID of the guild in which the command is available if it is a guild-specific command */
|
|
guildId?: bigint;
|
|
/** Whether to include full localization object (`name_localizations` and `description_localizations`) in the returned objects, instead of the `name_localized` and `description_localized` fields. Default false */
|
|
withLocalizations?: boolean;
|
|
}
|