fix: reaction remove tests (#811)

This commit is contained in:
Skillz4Killz
2021-04-10 17:03:32 -04:00
committed by GitHub
parent 2e21ea54e9
commit e163e2d109
24 changed files with 174 additions and 194 deletions

View File

@@ -11,12 +11,16 @@ export async function handleMessageReactionRemove(
if (message) {
const reaction = message.reactions?.find((reaction) =>
reaction.emoji.id === payload.emoji.id &&
// MUST USE == because discord sends null and we use undefined
reaction.emoji.id == payload.emoji.id &&
reaction.emoji.name === payload.emoji.name
);
if (reaction) {
reaction.count--;
if (reaction.count === 0) message.reactions = message.reactions?.filter(r => r.count !== 0);
if (!message.reactions?.length) message.reactions = undefined;
await cacheHandlers.set("messages", payload.message_id, message);
}
}

View File

@@ -10,13 +10,16 @@ export async function handleMessageReactionRemoveEmoji(
const message = await cacheHandlers.get("messages", payload.message_id);
if (message?.reactions) {
message.reactions = message.reactions?.filter(
message.reactions = message.reactions.filter(
(reaction) =>
!(
reaction.emoji.id === payload.emoji.id &&
// MUST USE == because discord sends null and we use undefined
reaction.emoji.id == payload.emoji.id &&
reaction.emoji.name === payload.emoji.name
),
);
if (!message.reactions.length) message.reactions = undefined
await cacheHandlers.set("messages", payload.message_id, message);
}

View File

@@ -16,11 +16,11 @@ Deno.test({
// Assertions
assertExists(category);
// Delay the execution by 5 seconds to allow CHANNEL_CREATE event to be processed
await delay(5000);
await delay(3000);
if (!cache.channels.has(category.id)) {
throw new Error(
"The channel seemed to be created but it was not cached.",
"The channel seemed to be created but it was not cached."
);
}
@@ -31,15 +31,15 @@ Deno.test({
name: `Discordeno-test-${num}`,
parentId: category.id,
})
),
)
);
// Delay the execution by 5 seconds to allow CHANNEL_CREATE event to be processed
await delay(5000);
await delay(3000);
// If every channel is not present in the cache, error out
if (!channels.every((c) => cache.channels.has(c.id))) {
throw new Error(
"The channels seemed to be created but it was not cached.",
"The channels seemed to be created but it was not cached."
);
}
@@ -49,7 +49,7 @@ Deno.test({
!channels.every((c) => ids.has(c.id))
) {
throw new Error(
"The category channel ids did not match with the category channels.",
"The category channel ids did not match with the category channels."
);
}
},

View File

@@ -16,23 +16,21 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel, save = false) {
if (save) tempData.channelId = channel.id;
// Delay the execution by 5 seconds to allow CHANNEL_CREATE event to be processed
await delay(5000);
await delay(3000);
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel seemed to be created but it was not cached.",
);
throw new Error("The channel seemed to be created but it was not cached.");
}
if (options.topic && channel.topic !== options.topic) {
throw new Error(
"The channel was supposed to have a topic but it does not appear to be the same topic.",
"The channel was supposed to have a topic but it does not appear to be the same topic."
);
}
if (options.bitrate && channel.bitrate !== options.bitrate) {
throw new Error(
"The channel was supposed to have a bitrate but it does not appear to be the same bitrate.",
"The channel was supposed to have a bitrate but it does not appear to be the same bitrate."
);
}
}
@@ -48,10 +46,13 @@ Deno.test({
Deno.test({
name: "[channel] create a new category channel",
async fn() {
await ifItFailsBlameWolf({
name: "Discordeno-test",
type: DiscordChannelTypes.GUILD_CATEGORY,
}, true);
await ifItFailsBlameWolf(
{
name: "Discordeno-test",
type: DiscordChannelTypes.GUILD_CATEGORY,
},
true
);
},
...defaultTestOptions,
});
@@ -75,10 +76,13 @@ Deno.test({
Deno.test({
name: "[channel] create a new voice channel",
async fn() {
await ifItFailsBlameWolf({
name: "Discordeno-test",
type: DiscordChannelTypes.GUILD_VOICE,
}, true);
await ifItFailsBlameWolf(
{
name: "Discordeno-test",
type: DiscordChannelTypes.GUILD_VOICE,
},
true
);
},
...defaultTestOptions,
});
@@ -86,11 +90,14 @@ Deno.test({
Deno.test({
name: "[channel] create a new voice channel with a bitrate",
async fn() {
await ifItFailsBlameWolf({
name: "discordeno-test",
type: DiscordChannelTypes.GUILD_VOICE,
bitrate: 32000,
}, true);
await ifItFailsBlameWolf(
{
name: "discordeno-test",
type: DiscordChannelTypes.GUILD_VOICE,
bitrate: 32000,
},
true
);
},
...defaultTestOptions,
});
@@ -98,11 +105,14 @@ Deno.test({
Deno.test({
name: "[channel] create a new voice channel with a user limit",
async fn() {
await ifItFailsBlameWolf({
name: "Discordeno-test",
type: DiscordChannelTypes.GUILD_VOICE,
userLimit: 32,
}, true);
await ifItFailsBlameWolf(
{
name: "Discordeno-test",
type: DiscordChannelTypes.GUILD_VOICE,
userLimit: 32,
},
true
);
},
...defaultTestOptions,
});
@@ -110,10 +120,13 @@ Deno.test({
Deno.test({
name: "[channel] create a new text channel with a rate limit per user",
async fn() {
await ifItFailsBlameWolf({
name: "Discordeno-test",
rateLimitPerUser: 2423,
}, true);
await ifItFailsBlameWolf(
{
name: "Discordeno-test",
rateLimitPerUser: 2423,
},
true
);
},
...defaultTestOptions,
});

View File

@@ -12,22 +12,22 @@ Deno.test({
name: "delete-channel",
});
// wait 5 seconds to give it time for CHANNEL_CREATE event
await delay(5000);
await delay(3000);
// Make sure the channel was created.
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel should have been created but it is not in the cache.",
"The channel should have been created but it is not in the cache."
);
}
// Delete the channel now without a reason
await deleteChannel(tempData.guildId, channel.id);
// wait 5 seconds to give it time for CHANNEL_DELETE event
await delay(5000);
await delay(3000);
// Make sure it is gone from cache
if (cache.channels.has(channel.id)) {
throw new Error(
"The channel should have been deleted but it is still in cache.",
"The channel should have been deleted but it is still in cache."
);
}
},
@@ -42,22 +42,22 @@ Deno.test({
name: "delete-channel",
});
// wait 5 seconds to give it time for CHANNEL_CREATE event
await delay(5000);
await delay(3000);
// Make sure the channel was created.
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel should have been created but it is not in the cache.",
"The channel should have been created but it is not in the cache."
);
}
// Delete the channel now without a reason
await deleteChannel(tempData.guildId, channel.id, "with a reason");
// wait 5 seconds to give it time for CHANNEL_DELETE event
await delay(5000);
await delay(3000);
// Make sure it is gone from cache
if (cache.channels.has(channel.id)) {
throw new Error(
"The channel should have been deleted but it is still in cache.",
"The channel should have been deleted but it is still in cache."
);
}
},

View File

@@ -17,7 +17,7 @@ Deno.test({
tempData.guildId = guild.id;
// Delay the execution by 5 seconds to allow GUILD_CREATE event to be processed
await delay(5000);
await delay(3000);
if (!cache.guilds.has(guild.id)) {
throw new Error("The guild seemed to be created but it was not cached.");

View File

@@ -14,7 +14,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", custom = false) {
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
if (!cache.messages.has(message.id)) {
throw new Error("The message seemed to be sent but it was not cached.");
@@ -33,7 +33,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", custom = false) {
name: "blamewolf",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
},
}
)
).id
}>`;
@@ -45,16 +45,16 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", custom = false) {
await message.addReaction(emojiId);
}
await delay(5000);
await delay(3000);
assertEquals(
await cache.messages
.get(message.id)
?.reactions?.filter(
(reaction: DiscordReaction) =>
reaction.emoji?.name === (custom ? "blamewolf" : "❤"),
reaction.emoji?.name === (custom ? "blamewolf" : "❤")
).length,
1,
1
);
}

View File

@@ -11,7 +11,7 @@ import { assertEquals, assertExists } from "../deps.ts";
async function ifItFailsBlameWolf(
type: "getter" | "raw",
custom = false,
ordered = false,
ordered = false
) {
const message = await sendMessage(tempData.channelId, "Hello World!");
@@ -19,12 +19,10 @@ async function ifItFailsBlameWolf(
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
if (!cache.messages.has(message.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
let emojiIds = ["❤", "😃"];
@@ -32,28 +30,32 @@ async function ifItFailsBlameWolf(
if (custom) {
emojiIds = [
`<: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
(
await createEmoji(
tempData.guildId,
"blamewolf",
"https://cdn.discordapp.com/emojis/814955268123000832.png",
{
name: "blamewolf",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
}
)
).id
}>`,
`<:blamewolf2:${
(await createEmoji(
tempData.guildId,
"blamewolf2",
"https://cdn.discordapp.com/emojis/814955268123000832.png",
{
name: "blamewolf2",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
},
)).id
(
await createEmoji(
tempData.guildId,
"blamewolf2",
"https://cdn.discordapp.com/emojis/814955268123000832.png",
{
name: "blamewolf2",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
}
)
).id
}>`,
];
}
@@ -64,12 +66,9 @@ async function ifItFailsBlameWolf(
await message.addReactions(emojiIds, ordered);
}
await delay(5000);
await delay(3000);
assertEquals(
await cache.messages.get(message.id)?.reactions?.length,
2,
);
assertEquals(await cache.messages.get(message.id)?.reactions?.length, 2);
}
Deno.test({

View File

@@ -12,17 +12,18 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
assertExists(channel);
// Wait few seconds for the channel create event to arrive and cache it
await delay(5000);
await delay(3000);
const message = type === "raw"
? await sendMessage(channel.id, "Hello World!")
: await channel.send("Hello World!");
const message =
type === "raw"
? await sendMessage(channel.id, "Hello World!")
: await channel.send("Hello World!");
// Assertions
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
if (!cache.messages.has(message.id)) {
throw new Error("The message seemed to be sent but it was not cached.");

View File

@@ -11,12 +11,10 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", reason?: string) {
// Assertions
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
// Make sure the message was created.
if (!cache.messages.has(message.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
// Delete the message now
@@ -27,11 +25,11 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", reason?: string) {
}
// Wait 5 seconds to give it time for MESSAGE_DELETE event
await delay(5000);
await delay(3000);
// Make sure it is gone from cache
if (cache.messages.has(message.id)) {
throw new Error(
"The message should have been deleted but it is still in cache.",
"The message should have been deleted but it is still in cache."
);
}
}

View File

@@ -14,12 +14,10 @@ async function ifItFailsBlameWolf(reason?: string) {
// Assertions
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
// Make sure the message was created.
if (!cache.messages.has(message.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
const secondMessage = await sendMessage(tempData.channelId, "Hello World 2!");
@@ -27,27 +25,25 @@ async function ifItFailsBlameWolf(reason?: string) {
// Assertions
assertExists(secondMessage);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
// Make sure the message was created.
if (!cache.messages.has(secondMessage.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
// Delete the message now
await deleteMessages(
tempData.channelId,
[message.id, secondMessage.id],
reason,
reason
);
// Wait 5 seconds to give it time for MESSAGE_DELETE event
await delay(5000);
await delay(3000);
// Make sure it is gone from cache
if (cache.messages.has(message.id) || cache.messages.has(secondMessage.id)) {
throw new Error(
"The message should have been deleted but it is still in cache.",
"The message should have been deleted but it is still in cache."
);
}
}

View File

@@ -11,7 +11,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
// Assertions
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
// Make sure the message was created.
if (!cache.messages.has(message.id)) {
throw new Error("The message seemed to be sent but it was not cached.");
@@ -24,7 +24,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
await message.edit("Goodbye World!");
}
// Wait 5 seconds to give it time for MESSAGE_UPDATE event
await delay(5000);
await delay(3000);
// Make sure it has been modified in cache
assertEquals(cache.messages.get(message.id)?.content, "Goodbye World!");

View File

@@ -10,12 +10,10 @@ Deno.test({
// Assertions
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
// Make sure the message was created.
if (!cache.messages.has(message.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
// Fetch the message

View File

@@ -8,11 +8,11 @@ Deno.test({
const message = await sendMessage(tempData.channelId, "Hello World!");
const secondMessage = await sendMessage(
tempData.channelId,
"Hello World 2!",
"Hello World 2!"
);
const thirdMessage = await sendMessage(
tempData.channelId,
"Hello World 3!",
"Hello World 3!"
);
// Assertions
@@ -20,16 +20,14 @@ Deno.test({
assertExists(secondMessage);
assertExists(thirdMessage);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
// Make sure the message was created.
if (
!cache.messages.has(message.id) ||
!cache.messages.has(secondMessage.id) ||
!cache.messages.has(thirdMessage.id)
) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
// Fetch the messages

View File

@@ -16,12 +16,10 @@ Deno.test({
// Assertions
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
// Make sure the message was created.
if (!cache.messages.has(message.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
await addReaction(message.channelId, message.id, "❤");
@@ -30,7 +28,7 @@ Deno.test({
const fetchedReactions = await getReactions(
tempData.channelId,
message.id,
"❤",
"❤"
);
// Check if getMessage has worked
assertEquals(fetchedReactions.size, 1);

View File

@@ -10,12 +10,10 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
if (!cache.messages.has(message.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
if (type === "raw") {
@@ -27,7 +25,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
const pins = await getPins(tempData.channelId);
assertEquals(
pins.filter((msg: DiscordenoMessage) => msg.id === message.id).length,
1,
1
);
}

View File

@@ -14,24 +14,19 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
// Assertions
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
// Make sure the message was created.
if (!cache.messages.has(message.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
// Add reactions to the message
await addReactions(message.channelId, message.id, ["❤", "😃", "🤫"]);
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_ALL event to be processed
await delay(5000);
await delay(3000);
// Be sure that the message has the reactions
assertEquals(
await cache.messages.get(message.id)?.reactions?.length,
3,
);
assertEquals(await cache.messages.get(message.id)?.reactions?.length, 3);
if (type === "raw") {
await removeAllReactions(message.channelId, message.id);
@@ -40,13 +35,10 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
}
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_REMOVE_ALL event to be processed
await delay(5000);
await delay(3000);
// Check if the reactions has been deleted
assertEquals(
await cache.messages.get(message.id)?.reactions,
undefined,
);
assertEquals(await cache.messages.get(message.id)?.reactions, undefined);
}
Deno.test({

View File

@@ -14,24 +14,19 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
// Assertions
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
// Make sure the message was created.
if (!cache.messages.has(message.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
// Add reactions to the message
await addReaction(message.channelId, message.id, "❤");
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_ALL event to be processed
await delay(5000);
await delay(3000);
// Be sure that the message has the reactions
assertEquals(
await cache.messages.get(message.id)?.reactions?.length,
1,
);
assertEquals(await cache.messages.get(message.id)?.reactions?.length, 1);
if (type === "raw") {
await removeReaction(message.channelId, message.id, "❤");
@@ -40,13 +35,10 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
}
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_REMOVE_ALL event to be processed
await delay(5000);
await delay(3000);
// Check if the reactions has been deleted
assertEquals(
await cache.messages.get(message.id)?.reactions,
undefined,
);
assertEquals(await cache.messages.get(message.id)?.reactions, undefined);
}
Deno.test({

View File

@@ -15,24 +15,19 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
// Assertions
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
// Make sure the message was created.
if (!cache.messages.has(message.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
// Add reactions to the message
await addReaction(message.channelId, message.id, "❤");
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_ALL event to be processed
await delay(5000);
await delay(3000);
// Be sure that the message has the reactions
assertEquals(
await cache.messages.get(message.id)?.reactions?.length,
1,
);
assertEquals(await cache.messages.get(message.id)?.reactions?.length, 1);
if (type === "raw") {
await removeReactionEmoji(message.channelId, message.id, "❤");
@@ -41,13 +36,10 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
}
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_REMOVE_ALL event to be processed
await delay(5000);
await delay(3000);
// Check if the reactions has been deleted
assertEquals(
await cache.messages.get(message.id)?.reactions,
undefined,
);
assertEquals(cache.messages.get(message.id)?.reactions, undefined);
}
Deno.test({

View File

@@ -15,44 +15,36 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
// Assertions
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
// Make sure the message was created.
if (!cache.messages.has(message.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
// Add reactions to the message
await addReaction(message.channelId, message.id, "❤");
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_ALL event to be processed
await delay(5000);
await delay(3000);
// Be sure that the message has the reactions
assertEquals(
await cache.messages.get(message.id)?.reactions?.length,
1,
);
assertEquals(await cache.messages.get(message.id)?.reactions?.length, 1);
if (type === "raw") {
await removeUserReaction(
message.channelId,
message.id,
"❤",
message.author.id,
message.author.id
);
} else {
//await message.removeUserReaction("❤", message.author.id);
}
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_REMOVE_ALL event to be processed
await delay(5000);
await delay(3000);
// Check if the reactions has been deleted
assertEquals(
await cache.messages.get(message.id)?.reactions,
undefined,
);
assertEquals(await cache.messages.get(message.id)?.reactions, undefined);
}
Deno.test({

View File

@@ -10,12 +10,10 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
assertExists(message);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delay(5000);
await delay(3000);
if (!cache.messages.has(message.id)) {
throw new Error(
"The message seemed to be sent but it was not cached.",
);
throw new Error("The message seemed to be sent but it was not cached.");
}
await pin(message.channelId, message.id);
@@ -24,7 +22,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
const pins = await getPins(tempData.channelId);
assertEquals(
pins.filter((msg: DiscordenoMessage) => msg.id === message.id).length,
1,
1
);
if (type === "raw") {
@@ -38,7 +36,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
assertEquals(
removedPins.filter((msg: DiscordenoMessage) => msg.id === message.id)
.length,
0,
0
);
}

View File

@@ -19,6 +19,10 @@ import "./channels/delete_channel.ts";
// Messages tests
import "./messages/add_reaction.ts";
import "./messages/add_reactions.ts";
import "./messages/remove_all_reactions.ts";
import "./messages/remove_reaction.ts";
import "./messages/remove_reaction_emoji.ts";
import "./messages/remove_user_reaction.ts";
import "./messages/create_message.ts";
import "./messages/delete_message.ts";
import "./messages/delete_messages.ts";
@@ -27,10 +31,6 @@ import "./messages/get_message.ts";
import "./messages/get_messages.ts";
import "./messages/get_reactions.ts";
import "./messages/pin_message.ts";
import "./messages/remove_all_reactions.ts";
import "./messages/remove_reaction.ts";
import "./messages/remove_reaction_emoji.ts";
import "./messages/remove_user_reaction.ts";
import "./messages/unpin_message.ts";
// Final cleanup

View File

@@ -0,0 +1,7 @@
export function delayUntil(maxMs: number, isReady: () => boolean) {
const maxed = Date.now() + maxMs;
while (Date.now() < maxed) {
if (isReady()) return;
}
}

View File

@@ -40,11 +40,12 @@ Deno.test({
"GUILDS",
"GUILD_EMOJIS",
"GUILD_MESSAGE_REACTIONS",
"GUILD_EMOJIS",
],
});
// Delay the execution by 5 seconds
await delay(5000);
await delay(3000);
// DELETE GUILDS IF LESS THAN 10 SERVERS AS SAFETY MEASURE
if (cache.guilds.size <= 10) {
@@ -147,7 +148,7 @@ Deno.test({
// }) as Channel;
// // Wait 5s for CHANNEL_UPDATE to fire
// await delay(5000);
// await delay(3000);
// // Assertions
// assertExists(channel);