mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 01:10:07 +00:00
refactor
This commit is contained in:
@@ -7,7 +7,7 @@ async function ifItFailsBlameWolf(bot: Bot, channelId: bigint, reason?: string)
|
||||
|
||||
// Assertions
|
||||
assertExists(message);
|
||||
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
|
||||
// Delay the execution by to allow MESSAGE_CREATE event to be processed
|
||||
await delayUntil(10000, () => bot.cache.messages.has(message.id));
|
||||
// Make sure the message was created.
|
||||
if (!bot.cache.messages.has(message.id)) {
|
||||
@@ -17,7 +17,7 @@ async function ifItFailsBlameWolf(bot: Bot, channelId: bigint, reason?: string)
|
||||
// Delete the message now
|
||||
await bot.helpers.deleteMessage(channelId, message.id, reason);
|
||||
|
||||
// Wait 5 seconds to give it time for MESSAGE_DELETE event
|
||||
// Wait to give it time for MESSAGE_DELETE event
|
||||
await delayUntil(10000, () => !bot.cache.messages.has(message.id));
|
||||
// Make sure it is gone from cache
|
||||
if (bot.cache.messages.has(message.id)) {
|
||||
@@ -26,17 +26,9 @@ async function ifItFailsBlameWolf(bot: Bot, channelId: bigint, reason?: string)
|
||||
}
|
||||
|
||||
export async function deleteMessageWithoutReasonTest(bot: Bot, channelId: bigint, t: Deno.TestContext) {
|
||||
console.log("⏳ [message] delete a message without a reason.");
|
||||
|
||||
await ifItFailsBlameWolf(bot, channelId);
|
||||
|
||||
console.log("✅ [message] delete a message without a reason.");
|
||||
}
|
||||
|
||||
export async function deleteMessageWithReasonTest(bot: Bot, channelId: bigint, t: Deno.TestContext) {
|
||||
console.log("⏳ [message] delete a message with a reason.");
|
||||
|
||||
await ifItFailsBlameWolf(bot, channelId, "with a reason");
|
||||
|
||||
console.log("✅ [message] delete a message with a reason.");
|
||||
}
|
||||
|
||||
10
tests/mod.ts
10
tests/mod.ts
@@ -82,10 +82,12 @@ Deno.test("[Bot] - Starting Tests", async (t) => {
|
||||
}
|
||||
|
||||
// CONDUCT ALL TESTS RELATED TO A MESSAGE HERE
|
||||
await Promise.all([
|
||||
deleteMessageWithoutReasonTest(bot, channel.id, t),
|
||||
deleteMessageWithReasonTest(bot, channel.id, t),
|
||||
]);
|
||||
await t.step("[message] delete message without a reason", async (t) => {
|
||||
await deleteMessageWithoutReasonTest(bot, channel.id, t);
|
||||
});
|
||||
await t.step("[message] delete message with a reason", async (t) => {
|
||||
await deleteMessageWithReasonTest(bot, channel.id, t);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user