Files
discordeno/tests/role/removeRole.ts
ITOH 81f8e0377c style: move to deno fmt (#1992)
* Create deno.json

* run format

* run format

* ci: only check formatting

* f

* Update settings.json

* Update settings.json
2022-02-04 15:00:04 +01:00

39 lines
1.2 KiB
TypeScript

import { roleChanges } from "../constants.ts";
import { assertEquals, assertExists } from "../deps.ts";
import { bot, guild } from "../mod.ts";
import { delayUntil } from "../utils.ts";
Deno.test({
name: "[Role] remove a role to a member",
fn: async (t) => {
const role = await bot.helpers.createRole(guild.id, {
name: "hoti",
});
assertExists(role);
// Delay the execution to allow event to be processed
await delayUntil(10000, () => bot.guilds.get(guild.id)?.roles.has(role.id));
assertExists(bot.guilds.get(guild.id)?.roles.has(role.id));
bot.events.guildMemberUpdate = function (bot, member, user) {
roleChanges.set(user.id, member.roles);
};
await bot.helpers.addRole(guild.id, bot.id, role.id, "Blame wolfy");
// Delay the execution to allow event to be processed
await delayUntil(10000, () => roleChanges.get(bot.id)?.includes(role.id));
assertEquals(roleChanges.get(bot.id)?.includes(role.id), true);
await bot.helpers.removeRole(guild.id, bot.id, role.id, "Blame wolfy");
// Delay the execution to allow event to be processed
await delayUntil(10000, () => !roleChanges.get(bot.id)?.includes(role.id));
assertEquals(roleChanges.get(bot.id)?.includes(role.id), false);
},
});