mirror of
https://github.com/swc-project/swc.git
synced 2024-12-21 12:41:54 +03:00
d60c3242af
swc_bundler: - Fix cycle detection for complex circular imports. (denoland/deno#10752) swc_ecma_transforms_typescript: - Allow using large values for an enum variant.
27 lines
965 B
TypeScript
27 lines
965 B
TypeScript
// Loaded from https://deno.land/x/discordeno@11.0.0-rc.2/src/helpers/emojis/get_emoji.ts
|
|
|
|
|
|
import { cacheHandlers } from "../../cache.ts";
|
|
import { rest } from "../../rest/rest.ts";
|
|
import type { Emoji } from "../../types/emojis/emoji.ts";
|
|
import { Errors } from "../../types/discordeno/errors.ts";
|
|
import { endpoints } from "../../util/constants.ts";
|
|
|
|
/**
|
|
* Returns an emoji for the given guild and emoji Id.
|
|
*
|
|
* ⚠️ **If you need this, you are probably doing something wrong. Always use cache.guilds.get()?.emojis
|
|
*/
|
|
export async function getEmoji(guildId: bigint, emojiId: bigint, addToCache = true) {
|
|
const result = await rest.runMethod<Emoji>("get", endpoints.GUILD_EMOJI(guildId, emojiId));
|
|
|
|
if (addToCache) {
|
|
const guild = await cacheHandlers.get("guilds", guildId);
|
|
if (!guild) throw new Error(Errors.GUILD_NOT_FOUND);
|
|
guild.emojis.set(emojiId, result);
|
|
await cacheHandlers.set("guilds", guildId, guild);
|
|
}
|
|
|
|
return result;
|
|
}
|