Files
discordeno/helpers/interactions/commands/getApplicationCommand.ts
2022-02-11 09:49:53 +00:00

16 lines
684 B
TypeScript

import type { ApplicationCommand } from "../../../types/interactions/commands/applicationCommand.ts";
import type { Bot } from "../../../bot.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, guildId?: bigint) {
const result = await bot.rest.runMethod<ApplicationCommand>(
bot.rest,
"get",
guildId
? bot.constants.endpoints.COMMANDS_GUILD_ID(bot.applicationId, guildId, commandId)
: bot.constants.endpoints.COMMANDS_ID(bot.applicationId, commandId),
);
return bot.transformers.applicationCommand(bot, result);
}