mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 01:10:07 +00:00
* perf(plugins/helpers,rest,site,template)!: uppercase rest methods There is no need for us to pass the methods in lower case and then use the `toUpperCase()` method everywhere. Therefore this PR changes every lowercase method to be uppercase (eg. `"get"` => `"GET"`). * template is old version
22 lines
779 B
TypeScript
22 lines
779 B
TypeScript
import { Collection } from "../../../util/collection.ts";
|
|
import type { Bot } from "../../../bot.ts";
|
|
import { DiscordApplicationCommand } from "../../../types/discord.ts";
|
|
|
|
/** Fetch all the commands for your application. If a guild id is not provided, it will fetch global commands. */
|
|
export async function getApplicationCommands(bot: Bot, guildId?: bigint) {
|
|
const result = await bot.rest.runMethod<DiscordApplicationCommand[]>(
|
|
bot.rest,
|
|
"GET",
|
|
guildId
|
|
? bot.constants.routes.COMMANDS_GUILD(bot.applicationId, guildId)
|
|
: bot.constants.routes.COMMANDS(bot.applicationId),
|
|
);
|
|
|
|
return new Collection(
|
|
result.map((res) => {
|
|
const command = bot.transformers.applicationCommand(bot, res);
|
|
return [command.id, command];
|
|
}),
|
|
);
|
|
}
|