Files
discordeno/helpers/interactions/commands/getApplicationCommand.ts
ITOH b00504ce07 perf(plugins/helpers,rest,site,template)!: uppercase rest methods (#2252)
* perf(plugins/helpers,rest,site,template)!: uppercase rest methods
There is no need for us to pass the methods in lower case and then use the `toUpperCase()` method everywhere. Therefore this PR changes every lowercase method to be uppercase (eg. `"get"` => `"GET"`).

* template is old version
2022-05-25 20:45:51 +02: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;
}