mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-19 04:38:17 +00:00
feat(handlers/webhook): change getSlashCommands() to return Collection (#410)
* refactor(handlers): getSlashCommands return Collection * wrongy wrong
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
|||||||
WebhookPayload,
|
WebhookPayload,
|
||||||
} from "../../types/mod.ts";
|
} from "../../types/mod.ts";
|
||||||
import { cache } from "../../util/cache.ts";
|
import { cache } from "../../util/cache.ts";
|
||||||
|
import { Collection } from "../../util/collection.ts";
|
||||||
import { endpoints, SLASH_COMMANDS_NAME_REGEX } from "../../util/constants.ts";
|
import { endpoints, SLASH_COMMANDS_NAME_REGEX } from "../../util/constants.ts";
|
||||||
import { botHasChannelPermissions } from "../../util/permissions.ts";
|
import { botHasChannelPermissions } from "../../util/permissions.ts";
|
||||||
import { urlToBase64 } from "../../util/utils.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. */
|
/** Fetch all of the global commands for your application. */
|
||||||
export async function getSlashCommands(guildID?: string) {
|
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
|
guildID
|
||||||
? endpoints.COMMANDS_GUILD(applicationID, guildID)
|
? endpoints.COMMANDS_GUILD(applicationID, guildID)
|
||||||
: endpoints.COMMANDS(applicationID),
|
: endpoints.COMMANDS(applicationID),
|
||||||
);
|
)) as SlashCommand[];
|
||||||
|
|
||||||
return result;
|
return new Collection(result.map((command) => [command.name, command]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user