From e952d1d9cb158fa3c3ce34dc509737e37080d6bc Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Sun, 24 Jan 2021 11:55:09 +0100 Subject: [PATCH] feat(handlers): add getSlashCommand() (#444) --- src/api/handlers/webhook.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/api/handlers/webhook.ts b/src/api/handlers/webhook.ts index 4b6643d89..bec85f4ea 100644 --- a/src/api/handlers/webhook.ts +++ b/src/api/handlers/webhook.ts @@ -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?