Files
discordeno/helpers/emojis/getEmojis.ts
T
Skillz4Killz 3a5bdce32d feat: helpers support strings in args (#2478)
* fix: helpers support strings in args

* fix: fmt
2022-09-15 20:59:02 -05:00

30 lines
996 B
TypeScript

import type { Bot } from "../../bot.ts";
import { Emoji } from "../../transformers/emoji.ts";
import { DiscordEmoji } from "../../types/discord.ts";
import { BigString } from "../../types/shared.ts";
import { Collection } from "../../util/collection.ts";
/**
* Gets the list of emojis for a guild.
*
* @param bot - The bot instance to use to make the request.
* @param guildId - The ID of the guild which to get the emojis of.
* @returns A collection of {@link Emoji} objects assorted by emoji ID.
*
* @see {@link https://discord.com/developers/docs/resources/emoji#list-guild-emojis}
*/
export async function getEmojis(bot: Bot, guildId: BigString): Promise<Collection<bigint, Emoji>> {
const results = await bot.rest.runMethod<DiscordEmoji[]>(
bot.rest,
"GET",
bot.constants.routes.GUILD_EMOJIS(guildId),
);
return new Collection(
results.map((result) => {
const emoji = bot.transformers.emoji(bot, result);
return [emoji.id!, emoji];
}),
);
}