feat(handlers): add getSlashCommand() (#444)

This commit is contained in:
ITOH
2021-01-24 11:55:09 +01:00
committed by GitHub
parent fada547388
commit e952d1d9cb

View File

@@ -9,6 +9,7 @@ import {
ExecuteSlashCommandOptions,
ExecuteWebhookOptions,
MessageCreateOptions,
SlashCommand,
UpsertSlashCommandOptions,
WebhookCreateOptions,
WebhookPayload,
@@ -214,6 +215,17 @@ export function createSlashCommand(options: CreateSlashCommandOptions) {
);
}
/** Fetchs the global command for the given ID. If a guildID is provided, the guild command will be fetched. */
export async function getSlashCommand(commandID: string, guildID?: string) {
const result = await RequestManager.get(
guildID
? endpoints.COMMANDS_GUILD_ID(applicationID, guildID, commandID)
: endpoints.COMMANDS_ID(applicationID, commandID),
);
return result as SlashCommand;
}
/** Fetch all of the global commands for your application. */
export function getSlashCommands(guildID?: string) {
// TODO: Should this be a returned as a collection?