mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { Bot } from "../../../src/bot.ts";
|
|
import { assertExists } from "../../deps.ts";
|
|
import { delayUntil } from "../../utils.ts";
|
|
|
|
export async function getEmojiTest(bot: Bot, guildId: bigint, t: Deno.TestContext) {
|
|
const emoji = await bot.helpers.createEmoji(guildId, {
|
|
name: "blamewolf",
|
|
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
|
roles: [],
|
|
});
|
|
|
|
// Assertions
|
|
assertExists(emoji);
|
|
|
|
// Delay the execution to allow event to be processed
|
|
await delayUntil(10000, async () => bot.cache.guilds.get(guildId)?.emojis?.has(emoji.id));
|
|
|
|
if (!bot.cache.guilds.get(guildId)?.emojis?.has(emoji.id)) {
|
|
throw new Error("The emoji seemed to be created but it was not cached.");
|
|
}
|
|
|
|
bot.cache.guilds.get(guildId)?.emojis?.delete(emoji.id);
|
|
|
|
const getEmoji = await bot.helpers.getEmoji(guildId, emoji.id, true);
|
|
|
|
// Assertions
|
|
assertExists(getEmoji);
|
|
|
|
// Delay the execution to allow event to be processed
|
|
await delayUntil(10000, async () => bot.cache.guilds.get(guildId)?.emojis?.has(emoji.id));
|
|
|
|
if (!bot.cache.guilds.get(guildId)?.emojis?.has(emoji.id)) {
|
|
throw new Error("The emoji didn't got added to cache after using the getEmoji function.");
|
|
}
|
|
}
|