This commit is contained in:
Skillz4Killz
2021-10-29 17:23:51 +00:00
committed by GitHub
parent ba3d222cb0
commit c824ef3bce
2 changed files with 8 additions and 14 deletions

View File

@@ -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.");
}

View File

@@ -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);
});
});
});