mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
tests: react with custom emojis tests
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
addReaction,
|
||||
cache,
|
||||
createEmoji,
|
||||
delay,
|
||||
DiscordReaction,
|
||||
sendMessage,
|
||||
@@ -8,7 +9,7 @@ import {
|
||||
import { defaultTestOptions, tempData } from "../ws/start_bot.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
|
||||
async function ifItFailsBlameWolf(type: "getter" | "raw") {
|
||||
async function ifItFailsBlameWolf(type: "getter" | "raw", custom = false) {
|
||||
const message = await sendMessage(tempData.channelId, "Hello World!");
|
||||
|
||||
// Assertions
|
||||
@@ -23,10 +24,27 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
|
||||
);
|
||||
}
|
||||
|
||||
let emojiId = "❤";
|
||||
|
||||
if (custom) {
|
||||
emojiId = `<:blamewolf:${
|
||||
(await createEmoji(
|
||||
tempData.guildId,
|
||||
"blamewolf",
|
||||
"https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
{
|
||||
name: "blamewolf",
|
||||
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
roles: [],
|
||||
},
|
||||
)).id
|
||||
}>`;
|
||||
}
|
||||
|
||||
if (type === "raw") {
|
||||
await addReaction(message.channelId, message.id, "❤");
|
||||
await addReaction(message.channelId, message.id, emojiId);
|
||||
} else {
|
||||
await message.addReaction("❤");
|
||||
await message.addReaction(emojiId);
|
||||
}
|
||||
|
||||
await delay(5000);
|
||||
@@ -34,7 +52,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
|
||||
assertEquals(
|
||||
await cache.messages.get(message.id)?.reactions?.filter((
|
||||
reaction: DiscordReaction,
|
||||
) => reaction.emoji?.name === "❤").length,
|
||||
) => reaction.emoji?.name === (custom ? "blamewolf" : "❤")).length,
|
||||
1,
|
||||
);
|
||||
}
|
||||
@@ -54,3 +72,19 @@ Deno.test({
|
||||
},
|
||||
...defaultTestOptions,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[message] add a custom reaction",
|
||||
async fn() {
|
||||
await ifItFailsBlameWolf("raw", true);
|
||||
},
|
||||
...defaultTestOptions,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[message] message.addReaction() with a custom reaction",
|
||||
async fn() {
|
||||
await ifItFailsBlameWolf("getter", true);
|
||||
},
|
||||
...defaultTestOptions,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user