From 0ec33b742064c0ca9d3565c3084661d20b9f5b9b Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Mon, 8 Mar 2021 17:39:40 +0100 Subject: [PATCH] feat(handlers/webhook): change getSlashCommands() to return Collection (#410) * refactor(handlers): getSlashCommands return Collection * wrongy wrong --- src/api/handlers/webhook.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/handlers/webhook.ts b/src/api/handlers/webhook.ts index 6047f0114..235d12749 100644 --- a/src/api/handlers/webhook.ts +++ b/src/api/handlers/webhook.ts @@ -20,6 +20,7 @@ import { WebhookPayload, } from "../../types/mod.ts"; import { cache } from "../../util/cache.ts"; +import { Collection } from "../../util/collection.ts"; import { endpoints, SLASH_COMMANDS_NAME_REGEX } from "../../util/constants.ts"; import { botHasChannelPermissions } from "../../util/permissions.ts"; import { urlToBase64 } from "../../util/utils.ts"; @@ -388,14 +389,13 @@ export async function getSlashCommand(commandID: string, guildID?: string) { /** Fetch all of the global commands for your application. */ export async function getSlashCommands(guildID?: string) { - // TODO: Should this be a returned as a collection? - const result = await RequestManager.get( + const result = (await RequestManager.get( guildID ? endpoints.COMMANDS_GUILD(applicationID, guildID) : endpoints.COMMANDS(applicationID), - ); + )) as SlashCommand[]; - return result; + return new Collection(result.map((command) => [command.name, command])); } /**