mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-15 19:08:17 +00:00
fix invite and ban tests
This commit is contained in:
@@ -1,24 +1,35 @@
|
||||
import { Bot } from "../../../src/bot.ts";
|
||||
import { CreateGuildBan } from "../../../src/types/mod.ts";
|
||||
import { assertEquals } from "../../deps.ts";
|
||||
import { delayUntil } from "../../utils.ts";
|
||||
|
||||
const banCounters = new Map<bigint, boolean>();
|
||||
|
||||
export async function banTest(bot: Bot, t: Deno.TestContext, guildId: bigint, id: bigint, options?: CreateGuildBan) {
|
||||
await bot.helpers.ban(guildId, 456226577798135808n);
|
||||
bot.events.guildBanAdd = function (bot, user, guildId) {
|
||||
banCounters.set(user.id, true);
|
||||
};
|
||||
|
||||
await bot.helpers.ban(guildId, id, options);
|
||||
|
||||
await delayUntil(10000, () => banCounters.get(id));
|
||||
|
||||
assertEquals(banCounters.get(id), true);
|
||||
}
|
||||
|
||||
export async function getBansTest(bot: Bot, t: Deno.TestContext, guildId: bigint) {
|
||||
await bot.helpers.getBans(guildId);
|
||||
}
|
||||
|
||||
export async function banTestWReason(
|
||||
bot: Bot,
|
||||
t: Deno.TestContext,
|
||||
guildId: bigint,
|
||||
id: bigint,
|
||||
options?: CreateGuildBan
|
||||
) {
|
||||
await bot.helpers.ban(guildId, 456226577798135808n, { reason: "Blame Wolf" });
|
||||
const bans = await bot.helpers.getBans(guildId);
|
||||
assertEquals(bans.size > 1, true);
|
||||
}
|
||||
|
||||
export async function unbanTest(bot: Bot, t: Deno.TestContext, guildId: bigint, id: bigint) {
|
||||
await bot.helpers.unban(guildId, 456226577798135808n);
|
||||
bot.events.guildBanRemove = function (bot, user, guildId) {
|
||||
banCounters.set(user.id, false);
|
||||
};
|
||||
|
||||
await bot.helpers.unban(guildId, id);
|
||||
|
||||
await delayUntil(10000, () => !banCounters.get(id));
|
||||
|
||||
assertEquals(banCounters.get(id), false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user