Files
discordeno/helpers/interactions/commands/getApplicationCommand.ts
ITOH 03996c5f58 refactor: revert "feat: base plugin lib idea (#2308)" (#2336)
* Revert "feat: base plugin lib idea (#2308)"

This reverts commit ffe7cdbc6f.

* fmt
2022-07-02 14:24:43 +01:00

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;
}