mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
change: prettier code
This commit is contained in:
committed by
GitHub Action
parent
059614e695
commit
30e34a7aba
@@ -3,19 +3,19 @@ import { assertExists } from "../../deps.ts";
|
||||
import { delayUntil } from "../../utils.ts";
|
||||
|
||||
export async function createEmojiTest(bot: Bot, guildId: bigint, t: Deno.TestContext) {
|
||||
const emoji = await bot.helpers.createEmoji(guildId, {
|
||||
name: "blamewolf",
|
||||
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
roles: [],
|
||||
});
|
||||
const emoji = await bot.helpers.createEmoji(guildId, {
|
||||
name: "blamewolf",
|
||||
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
roles: [],
|
||||
});
|
||||
|
||||
// Assertions
|
||||
assertExists(emoji);
|
||||
// Assertions
|
||||
assertExists(emoji);
|
||||
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be created but it was not cached.");
|
||||
}
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be created but it was not cached.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,35 +3,35 @@ import { assertExists } from "../../deps.ts";
|
||||
import { delayUntil } from "../../utils.ts";
|
||||
|
||||
export async function ifItFailsBlameWolf(bot: Bot, guildId: bigint, reason?: string) {
|
||||
const emoji = await bot.helpers.createEmoji(guildId, {
|
||||
name: "blamewolf",
|
||||
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
roles: [],
|
||||
});
|
||||
const emoji = await bot.helpers.createEmoji(guildId, {
|
||||
name: "blamewolf",
|
||||
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
roles: [],
|
||||
});
|
||||
|
||||
// Assertions
|
||||
assertExists(emoji);
|
||||
// Assertions
|
||||
assertExists(emoji);
|
||||
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be created but it was not cached.");
|
||||
}
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be created but it was not cached.");
|
||||
}
|
||||
|
||||
await bot.helpers.deleteEmoji(guildId, emoji.id, reason);
|
||||
await bot.helpers.deleteEmoji(guildId, emoji.id, reason);
|
||||
|
||||
await delayUntil(10000, async () => !(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
await delayUntil(10000, async () => !(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
|
||||
if ((await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be deleted but it's still cached.");
|
||||
}
|
||||
if ((await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be deleted but it's still cached.");
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteEmojiWithReasonTest(bot: Bot, guildId: bigint, t: Deno.TestContext) {
|
||||
await ifItFailsBlameWolf(bot, guildId);
|
||||
await ifItFailsBlameWolf(bot, guildId);
|
||||
}
|
||||
|
||||
export async function deleteEmojiWithoutReasonTest(bot: Bot, guildId: bigint, t: Deno.TestContext) {
|
||||
await ifItFailsBlameWolf(bot, guildId, "with a reason");
|
||||
await ifItFailsBlameWolf(bot, guildId, "with a reason");
|
||||
}
|
||||
|
||||
@@ -3,29 +3,32 @@ import { assertExists } from "../../deps.ts";
|
||||
import { delayUntil } from "../../utils.ts";
|
||||
|
||||
export async function editEmojiTest(bot: Bot, guildId: bigint, t: Deno.TestContext) {
|
||||
const emoji = await bot.helpers.createEmoji(guildId, {
|
||||
name: "blamewolf",
|
||||
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
roles: [],
|
||||
});
|
||||
const emoji = await bot.helpers.createEmoji(guildId, {
|
||||
name: "blamewolf",
|
||||
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
roles: [],
|
||||
});
|
||||
|
||||
// Assertions
|
||||
assertExists(emoji);
|
||||
// Assertions
|
||||
assertExists(emoji);
|
||||
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be created but it was not cached.");
|
||||
}
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be created but it was not cached.");
|
||||
}
|
||||
|
||||
await bot.helpers.editEmoji(guildId, emoji.id, {
|
||||
name: "blamewolf_infinite",
|
||||
});
|
||||
await bot.helpers.editEmoji(guildId, emoji.id, {
|
||||
name: "blamewolf_infinite",
|
||||
});
|
||||
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.get(emoji.id)?.name === "blamewolf_infinite");
|
||||
await delayUntil(
|
||||
10000,
|
||||
async () => (await bot.cache.guilds.get(guildId))?.emojis?.get(emoji.id)?.name === "blamewolf_infinite"
|
||||
);
|
||||
|
||||
if ((await bot.cache.guilds.get(guildId))?.emojis?.get(emoji.id)?.name !== "blamewolf_infinite") {
|
||||
throw new Error("The emoji seemed to be edited but the cache was not updated.");
|
||||
}
|
||||
if ((await bot.cache.guilds.get(guildId))?.emojis?.get(emoji.id)?.name !== "blamewolf_infinite") {
|
||||
throw new Error("The emoji seemed to be edited but the cache was not updated.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,33 +3,33 @@ import { assertExists } from "../../deps.ts";
|
||||
import { delayUntil } from "../../utils.ts";
|
||||
|
||||
export async function getEmojiTest(bot: Bot, guildId: bigint, t: Deno.TestContext) {
|
||||
const emoji = await bot.helpers.createEmoji(guildId, {
|
||||
name: "blamewolf",
|
||||
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
roles: [],
|
||||
});
|
||||
const emoji = await bot.helpers.createEmoji(guildId, {
|
||||
name: "blamewolf",
|
||||
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
roles: [],
|
||||
});
|
||||
|
||||
// Assertions
|
||||
assertExists(emoji);
|
||||
// Assertions
|
||||
assertExists(emoji);
|
||||
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be created but it was not cached.");
|
||||
}
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be created but it was not cached.");
|
||||
}
|
||||
|
||||
(await bot.cache.guilds.get(guildId))?.emojis?.delete(emoji.id);
|
||||
(await bot.cache.guilds.get(guildId))?.emojis?.delete(emoji.id);
|
||||
|
||||
const getEmoji = await bot.helpers.getEmoji(guildId, emoji.id, true);
|
||||
const getEmoji = await bot.helpers.getEmoji(guildId, emoji.id, true);
|
||||
|
||||
// Assertions
|
||||
assertExists(getEmoji);
|
||||
// Assertions
|
||||
assertExists(getEmoji);
|
||||
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji didn't got added to cache after using the getEmoji function.");
|
||||
}
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji didn't got added to cache after using the getEmoji function.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,25 +3,25 @@ import { assertExists } from "../../deps.ts";
|
||||
import { delayUntil } from "../../utils.ts";
|
||||
|
||||
export async function getEmojisTest(bot: Bot, guildId: bigint, t: Deno.TestContext) {
|
||||
const emoji = await bot.helpers.createEmoji(guildId, {
|
||||
name: "blamewolf",
|
||||
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
roles: [],
|
||||
});
|
||||
const emoji = await bot.helpers.createEmoji(guildId, {
|
||||
name: "blamewolf",
|
||||
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
||||
roles: [],
|
||||
});
|
||||
|
||||
// Assertions
|
||||
assertExists(emoji);
|
||||
// Assertions
|
||||
assertExists(emoji);
|
||||
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id));
|
||||
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be created but it was not cached.");
|
||||
}
|
||||
if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) {
|
||||
throw new Error("The emoji seemed to be created but it was not cached.");
|
||||
}
|
||||
|
||||
const emojis = await bot.helpers.getEmojis(guildId);
|
||||
const emojis = await bot.helpers.getEmojis(guildId);
|
||||
|
||||
if (emojis.size === 0) {
|
||||
throw new Error("The getEmojis function returned 0 emojis.");
|
||||
}
|
||||
if (emojis.size === 0) {
|
||||
throw new Error("The getEmojis function returned 0 emojis.");
|
||||
}
|
||||
}
|
||||
|
||||
+14
-14
@@ -28,11 +28,11 @@ import { pinMessageTests } from "./helpers/messages/pin.ts";
|
||||
import { removeAllReactionTests, removeReactionEmojiTest, removeReactionTest } from "./helpers/messages/reactions.ts";
|
||||
import { createChannelTests } from "./helpers/channels/createChannel.ts";
|
||||
import { deleteChannelTests } from "./helpers/channels/deleteChannel.ts";
|
||||
import {createEmojiTest} from "./helpers/emojis/createEmoji.ts";
|
||||
import {deleteEmojiWithoutReasonTest, deleteEmojiWithReasonTest} from "./helpers/emojis/deleteEmoji.ts";
|
||||
import {editEmojiTest} from "./helpers/emojis/editEmoji.ts";
|
||||
import {getEmojiTest} from "./helpers/emojis/getEmoji.ts";
|
||||
import {getEmojisTest} from "./helpers/emojis/getEmojis.ts";
|
||||
import { createEmojiTest } from "./helpers/emojis/createEmoji.ts";
|
||||
import { deleteEmojiWithoutReasonTest, deleteEmojiWithReasonTest } from "./helpers/emojis/deleteEmoji.ts";
|
||||
import { editEmojiTest } from "./helpers/emojis/editEmoji.ts";
|
||||
import { getEmojiTest } from "./helpers/emojis/getEmoji.ts";
|
||||
import { getEmojisTest } from "./helpers/emojis/getEmojis.ts";
|
||||
|
||||
Deno.test("[Bot] - Starting Tests", async (t) => {
|
||||
// CHANGE TO TRUE WHEN DEBUGGING SANITIZATION ERRORS
|
||||
@@ -481,13 +481,13 @@ Deno.test("[Bot] - Starting Tests", async (t) => {
|
||||
// EMOJIS TESTS GROUPED
|
||||
await t.step("Emojis related tests", async (t) => {
|
||||
await Promise.all([
|
||||
t.step({
|
||||
name: "[emoji] create an emoji",
|
||||
fn: async (t) => {
|
||||
await createEmojiTest(bot, guild.id, t);
|
||||
},
|
||||
...sanitizeMode,
|
||||
}),
|
||||
t.step({
|
||||
name: "[emoji] create an emoji",
|
||||
fn: async (t) => {
|
||||
await createEmojiTest(bot, guild.id, t);
|
||||
},
|
||||
...sanitizeMode,
|
||||
}),
|
||||
t.step({
|
||||
name: "[emoji] delete an emoji without a reason",
|
||||
fn: async (t) => {
|
||||
@@ -522,9 +522,9 @@ Deno.test("[Bot] - Starting Tests", async (t) => {
|
||||
await getEmojisTest(bot, guild.id, t);
|
||||
},
|
||||
...sanitizeMode,
|
||||
})
|
||||
}),
|
||||
]);
|
||||
})
|
||||
});
|
||||
|
||||
await stopBot(bot);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user