mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
fmt files damn son
This commit is contained in:
+38
-14
@@ -1,11 +1,11 @@
|
||||
import { defaultTestOptions, tempData } from "../ws/start_bot.ts";
|
||||
import {assertEquals, assertExists} from "../deps.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { cache } from "../../src/cache.ts";
|
||||
import { delayUntil } from "../util/delay_until.ts";
|
||||
import {addRole} from "../../src/helpers/roles/add_role.ts";
|
||||
import {createRole} from "../../src/helpers/roles/create_role.ts";
|
||||
import {botId} from "../../src/bot.ts";
|
||||
import {removeRole} from "../../src/helpers/roles/remove_role.ts";
|
||||
import { addRole } from "../../src/helpers/roles/add_role.ts";
|
||||
import { createRole } from "../../src/helpers/roles/create_role.ts";
|
||||
import { botId } from "../../src/bot.ts";
|
||||
import { removeRole } from "../../src/helpers/roles/remove_role.ts";
|
||||
|
||||
async function ifItFailsBlameWolf(type: "getter" | "raw", reason?: string) {
|
||||
const role = await createRole(tempData.guildId, {
|
||||
@@ -15,7 +15,10 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", reason?: string) {
|
||||
assertExists(role);
|
||||
|
||||
// Delay the execution by 5 seconds to allow GUILD_ROLE_CREATE event to be processed
|
||||
await delayUntil(10000, () => cache.guilds.get(tempData.guildId)?.roles.has(role.id));
|
||||
await delayUntil(
|
||||
10000,
|
||||
() => cache.guilds.get(tempData.guildId)?.roles.has(role.id),
|
||||
);
|
||||
|
||||
if (!cache.guilds.get(tempData.guildId)?.roles.has(role.id)) {
|
||||
throw new Error(`The role seemed to be created but it was not cached.`);
|
||||
@@ -28,24 +31,45 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", reason?: string) {
|
||||
}
|
||||
|
||||
// Delay the execution by 5 seconds to allow GUILD_MEMBER_UPDATE event to be processed
|
||||
await delayUntil(10000, () => cache.members.get(botId)?.guilds.get(tempData.guildId).roles.includes(role.id));
|
||||
await delayUntil(
|
||||
10000,
|
||||
() =>
|
||||
cache.members.get(botId)?.guilds.get(tempData.guildId).roles.includes(
|
||||
role.id,
|
||||
),
|
||||
);
|
||||
|
||||
if (type === "raw") {
|
||||
await removeRole(tempData.guildId, botId, role.id, reason);
|
||||
} else {
|
||||
await cache.members.get(botId).removeRole(tempData.guildId, role.id, reason);
|
||||
await cache.members.get(botId).removeRole(
|
||||
tempData.guildId,
|
||||
role.id,
|
||||
reason,
|
||||
);
|
||||
}
|
||||
|
||||
// Delay the execution by 5 seconds to allow GUILD_MEMBER_UPDATE event to be processed
|
||||
await delayUntil(10000, () => !cache.members.get(botId)?.guilds.get(tempData.guildId).roles.includes(role.id));
|
||||
await delayUntil(
|
||||
10000,
|
||||
() =>
|
||||
!cache.members.get(botId)?.guilds.get(tempData.guildId).roles.includes(
|
||||
role.id,
|
||||
),
|
||||
);
|
||||
|
||||
assertEquals(cache.members.get(botId)?.guilds.get(tempData.guildId).roles.includes(role.id), false);
|
||||
assertEquals(
|
||||
cache.members.get(botId)?.guilds.get(tempData.guildId).roles.includes(
|
||||
role.id,
|
||||
),
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
Deno.test({
|
||||
name: "[role] remove a role without a reason",
|
||||
async fn() {
|
||||
await ifItFailsBlameWolf("raw")
|
||||
await ifItFailsBlameWolf("raw");
|
||||
},
|
||||
...defaultTestOptions,
|
||||
});
|
||||
@@ -53,7 +77,7 @@ Deno.test({
|
||||
Deno.test({
|
||||
name: "[role] remove a role with a reason",
|
||||
async fn() {
|
||||
await ifItFailsBlameWolf("raw", "with a reason")
|
||||
await ifItFailsBlameWolf("raw", "with a reason");
|
||||
},
|
||||
...defaultTestOptions,
|
||||
});
|
||||
@@ -61,7 +85,7 @@ Deno.test({
|
||||
Deno.test({
|
||||
name: "[role] member.removeRole() without a reason",
|
||||
async fn() {
|
||||
await ifItFailsBlameWolf("getter")
|
||||
await ifItFailsBlameWolf("getter");
|
||||
},
|
||||
...defaultTestOptions,
|
||||
});
|
||||
@@ -69,7 +93,7 @@ Deno.test({
|
||||
Deno.test({
|
||||
name: "[role] member.removeRole() with a reason",
|
||||
async fn() {
|
||||
await ifItFailsBlameWolf("getter", "with a reason")
|
||||
await ifItFailsBlameWolf("getter", "with a reason");
|
||||
},
|
||||
...defaultTestOptions,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user