mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
style: move to deno fmt (#1992)
* Create deno.json * run format * run format * ci: only check formatting * f * Update settings.json * Update settings.json
This commit is contained in:
+10
-14
@@ -2,32 +2,28 @@
|
||||
|
||||
Unit tests are MANDATORY!
|
||||
|
||||
Every time you create a new function in the library, you must also add a unit
|
||||
test for it. A PR should/will not be merged without a valid unit test for it. If
|
||||
you are unable to create a unit test, please leave a comment in your PR asking
|
||||
for help.
|
||||
Every time you create a new function in the library, you must also add a unit test for it. A PR should/will not be
|
||||
merged without a valid unit test for it. If you are unable to create a unit test, please leave a comment in your PR
|
||||
asking for help.
|
||||
|
||||
## Test Locally
|
||||
|
||||
You do not need to push to the github repo to have the CI do the tests for you.
|
||||
You can test them locally by doing the following:
|
||||
You do not need to push to the github repo to have the CI do the tests for you. You can test them locally by doing the
|
||||
following:
|
||||
|
||||
```shell
|
||||
DISCORD_TOKEN=YOUR_BOT_TOKEN_HERE deno test --no-check -A tests/mod.ts
|
||||
```
|
||||
|
||||
> Please note that the token you use should be for a trivial unused bot. Never
|
||||
> use your main bot tokens for this.
|
||||
> Please note that the token you use should be for a trivial unused bot. Never use your main bot tokens for this.
|
||||
|
||||
## Ordering
|
||||
|
||||
The order of unit tests is very important. Please do not move/change the order
|
||||
of the tests unless you know what you are doing. Certain tests depend on other
|
||||
previous tests. You may add a test but becareful where you add it.
|
||||
The order of unit tests is very important. Please do not move/change the order of the tests unless you know what you are
|
||||
doing. Certain tests depend on other previous tests. You may add a test but becareful where you add it.
|
||||
|
||||
## Naming
|
||||
|
||||
Each function should have it's own separate file for it's tests. The file should
|
||||
be organized under it's main category which will be the `[]` portion of the
|
||||
tests name. For example, `[guild] create a new guild` will be found in
|
||||
Each function should have it's own separate file for it's tests. The file should be organized under it's main category
|
||||
which will be the `[]` portion of the tests name. For example, `[guild] create a new guild` will be found in
|
||||
`tests/guilds/create_guild.ts`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ChannelTypes, CreateGuildChannel, OverwriteTypes } from "../../mod.ts";
|
||||
import { CACHED_COMMUNITY_GUILD_ID } from "../constants.ts";
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot, guild } from "../mod.ts";
|
||||
import { delayUntil } from "../utils.ts";
|
||||
|
||||
@@ -28,7 +28,7 @@ async function createChannelTests(guildId: bigint, options: CreateGuildChannel,
|
||||
|
||||
if (options.permissionOverwrites && channel.permissionOverwrites?.length !== options.permissionOverwrites.length) {
|
||||
throw new Error(
|
||||
"The channel was supposed to have a permissionOverwrites but it does not appear to be the same permissionOverwrites."
|
||||
"The channel was supposed to have a permissionOverwrites but it does not appear to be the same permissionOverwrites.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ Deno.test({
|
||||
name: "Discordeno-test",
|
||||
type: ChannelTypes.GuildCategory,
|
||||
},
|
||||
false
|
||||
false,
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -62,7 +62,7 @@ Deno.test({
|
||||
await createChannelTests(
|
||||
CACHED_COMMUNITY_GUILD_ID,
|
||||
{ name: "Discordeno-test", type: ChannelTypes.GuildNews },
|
||||
true
|
||||
true,
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -75,7 +75,7 @@ Deno.test({
|
||||
name: "Discordeno-test",
|
||||
type: ChannelTypes.GuildVoice,
|
||||
},
|
||||
false
|
||||
false,
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -89,7 +89,7 @@ Deno.test({
|
||||
type: ChannelTypes.GuildVoice,
|
||||
bitrate: 32000,
|
||||
},
|
||||
false
|
||||
false,
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -103,7 +103,7 @@ Deno.test({
|
||||
type: ChannelTypes.GuildVoice,
|
||||
userLimit: 32,
|
||||
},
|
||||
false
|
||||
false,
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -116,7 +116,7 @@ Deno.test({
|
||||
name: "Discordeno-test",
|
||||
rateLimitPerUser: 2423,
|
||||
},
|
||||
false
|
||||
false,
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -142,7 +142,7 @@ Deno.test({
|
||||
},
|
||||
],
|
||||
},
|
||||
false
|
||||
false,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ChannelTypes } from "../../src/types/channels/channelTypes.ts";
|
||||
import { CACHED_COMMUNITY_GUILD_ID } from "../constants.ts";
|
||||
import { assertNotEquals, assertExists } from "../deps.ts";
|
||||
import { assertExists, assertNotEquals } from "../deps.ts";
|
||||
import { bot } from "../mod.ts";
|
||||
|
||||
Deno.test("[stage] Create a stage instance", async (t) => {
|
||||
@@ -12,11 +12,11 @@ Deno.test("[stage] Create a stage instance", async (t) => {
|
||||
assertExists(instance);
|
||||
|
||||
await t.step("[stage] Edit a stage instance", async () => {
|
||||
const edited = await bot.helpers.updateStageInstance(stage.id, {
|
||||
topic: "edited"
|
||||
})
|
||||
assertNotEquals(edited.topic, stage.topic);
|
||||
})
|
||||
const edited = await bot.helpers.updateStageInstance(stage.id, {
|
||||
topic: "edited",
|
||||
});
|
||||
assertNotEquals(edited.topic, stage.topic);
|
||||
});
|
||||
|
||||
await t.step("[stage] Delete a stage instance", async () => {
|
||||
await bot.helpers.deleteStageInstance(stage.id);
|
||||
|
||||
@@ -29,7 +29,7 @@ Deno.test("[thread] Start a thread", async (t) => {
|
||||
});
|
||||
|
||||
await t.step("[thread] Get archived threads", async (t) => {
|
||||
const archived = await bot.helpers.getArchivedThreads(channel.id);
|
||||
const archived = await bot.helpers.getArchivedThreads(channel.id);
|
||||
assertEquals(archived.threads.size, 0);
|
||||
assertEquals(archived.members.size, 0);
|
||||
|
||||
|
||||
+1
-1
@@ -3,9 +3,9 @@ export {
|
||||
assertEquals,
|
||||
assertExists,
|
||||
assertNotEquals,
|
||||
assertRejects,
|
||||
assertThrows,
|
||||
assertThrowsAsync,
|
||||
assertRejects,
|
||||
} from "https://deno.land/std@0.115.1/testing/asserts.ts";
|
||||
export * from "https://deno.land/x/discordeno_cache_plugin@0.0.21/mod.ts";
|
||||
export * from "https://deno.land/x/discordeno_permissions_plugin@0.0.15/mod.ts";
|
||||
|
||||
@@ -4,7 +4,10 @@ import { bot } from "../mod.ts";
|
||||
Deno.test("[emoji] Create an emoji url", async () => {
|
||||
assertEquals(
|
||||
bot.helpers.emojiUrl(785403373817823272n, false),
|
||||
"https://cdn.discordapp.com/emojis/785403373817823272.png"
|
||||
"https://cdn.discordapp.com/emojis/785403373817823272.png",
|
||||
);
|
||||
assertEquals(
|
||||
bot.helpers.emojiUrl(785403373817823272n, true),
|
||||
"https://cdn.discordapp.com/emojis/785403373817823272.gif",
|
||||
);
|
||||
assertEquals(bot.helpers.emojiUrl(785403373817823272n, true), "https://cdn.discordapp.com/emojis/785403373817823272.gif");
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@ Deno.test({
|
||||
assertEquals(bot.helpers.guildIconURL(guild.id, guild.icon), undefined);
|
||||
assertEquals(
|
||||
bot.helpers.guildIconURL(785384884197392384n, 3837424427068676005442449262648382018748n),
|
||||
"https://cdn.discordapp.com/icons/785384884197392384/46f50fb412eab14ec455d5cf777154bc.jpg?size=128"
|
||||
"https://cdn.discordapp.com/icons/785384884197392384/46f50fb412eab14ec455d5cf777154bc.jpg?size=128",
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -20,7 +20,7 @@ Deno.test({
|
||||
bot.helpers.guildBannerURL(613425648685547541n, {
|
||||
banner: 3919584870146358272366452115178209474142n,
|
||||
}),
|
||||
"https://cdn.discordapp.com/banners/613425648685547541/84c4964c115c128fb9100952c3b4f65e.jpg?size=128"
|
||||
"https://cdn.discordapp.com/banners/613425648685547541/84c4964c115c128fb9100952c3b4f65e.jpg?size=128",
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -31,7 +31,7 @@ Deno.test({
|
||||
assertEquals(bot.helpers.guildSplashURL(guild.id, guild.splash), undefined);
|
||||
assertEquals(
|
||||
bot.helpers.guildSplashURL(785384884197392384n, 3837424427068676005442449262648382018748n),
|
||||
"https://cdn.discordapp.com/splashes/785384884197392384/46f50fb412eab14ec455d5cf777154bc.jpg?size=128"
|
||||
"https://cdn.discordapp.com/splashes/785384884197392384/46f50fb412eab14ec455d5cf777154bc.jpg?size=128",
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ export async function categoryChildrenTest(guildId: bigint) {
|
||||
name: `Discordeno-test-${num}`,
|
||||
parentId: category.id,
|
||||
})
|
||||
)
|
||||
),
|
||||
);
|
||||
// Delay the execution to allow event to be processed
|
||||
await delayUntil(10000, () => channels.every((c) => bot.channels.has(c.id)));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CreateGuildChannel } from "../../../src/types/guilds/createGuildChannel.ts";
|
||||
import { ChannelTypes } from "../../../src/types/mod.ts";
|
||||
import { assertExists, assertEquals } from "../../deps.ts";
|
||||
import { assertEquals, assertExists } from "../../deps.ts";
|
||||
import { bot } from "../../mod.ts";
|
||||
import { delayUntil } from "../../utils.ts";
|
||||
|
||||
@@ -32,7 +32,7 @@ export async function createChannelTests(
|
||||
|
||||
if (options.permissionOverwrites && channel.permissionOverwrites?.length !== options.permissionOverwrites.length) {
|
||||
throw new Error(
|
||||
"The channel was supposed to have a permissionOverwrites but it does not appear to be the same permissionOverwrites."
|
||||
"The channel was supposed to have a permissionOverwrites but it does not appear to be the same permissionOverwrites.",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ChannelTypes, OverwriteTypes } from "../../../mod.ts";
|
||||
import { assertExists, assertEquals, channelOverwriteHasPermission } from "../../deps.ts";
|
||||
import { assertEquals, assertExists, channelOverwriteHasPermission } from "../../deps.ts";
|
||||
import { bot } from "../../mod.ts";
|
||||
import { delayUntil } from "../../utils.ts";
|
||||
|
||||
@@ -33,7 +33,7 @@ export async function deleteChannelOverwriteTests(guildId: bigint) {
|
||||
channelOverwriteHasPermission(channel.guildId, bot.id, bot.channels.get(channel.id)?.permissionOverwrites || [], [
|
||||
"VIEW_CHANNEL",
|
||||
]),
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
await bot.helpers.deleteChannelOverwrite(channel.id, bot.id);
|
||||
|
||||
@@ -21,7 +21,7 @@ export async function editChannelTests(guildId: bigint, options: { reason?: stri
|
||||
{
|
||||
name: "new-name",
|
||||
},
|
||||
options.reason
|
||||
options.reason,
|
||||
);
|
||||
|
||||
// wait to give it time for events to process
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assertExists, assertEquals } from "../../deps.ts";
|
||||
import { assertEquals, assertExists } from "../../deps.ts";
|
||||
import { bot } from "../../mod.ts";
|
||||
import { delayUntil } from "../../utils.ts";
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ export async function editGuildTests(guildId: bigint) {
|
||||
{
|
||||
name: "Discordeno Test 1.0",
|
||||
},
|
||||
0
|
||||
0,
|
||||
);
|
||||
|
||||
// Assertions
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assertExists, assertEquals } from "../../deps.ts";
|
||||
import { assertEquals, assertExists } from "../../deps.ts";
|
||||
import { bot } from "../../mod.ts";
|
||||
|
||||
export async function getBanTests(guildId: bigint) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assertExists, assertEquals } from "../../deps.ts";
|
||||
import { assertEquals, assertExists } from "../../deps.ts";
|
||||
import { bot } from "../../mod.ts";
|
||||
|
||||
export async function getGuildTests(guildId: bigint) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Bot } from "../../../src/bot.ts";
|
||||
import { assertExists, assertEquals } from "../../deps.ts";
|
||||
import { assertEquals, assertExists } from "../../deps.ts";
|
||||
|
||||
export async function getVanityURLTests(guildId: bigint) {
|
||||
// TODO: VANITY IS BROKEN ATM FROM DISCORDS SIDE
|
||||
|
||||
@@ -4,27 +4,25 @@ import { CreateScheduledEvent, ScheduledEventEntityType } from "../../../../src/
|
||||
import { CACHED_COMMUNITY_GUILD_ID } from "../../../constants.ts";
|
||||
import { assertEquals, assertExists } from "../../../deps.ts";
|
||||
|
||||
|
||||
export async function createScheduledEventTests(
|
||||
bot: Bot,
|
||||
guildId: bigint,
|
||||
options: CreateScheduledEvent,
|
||||
t: Deno.TestContext
|
||||
t: Deno.TestContext,
|
||||
) {
|
||||
const channel = [
|
||||
ScheduledEventEntityType.StageInstance,
|
||||
ScheduledEventEntityType.Voice,
|
||||
ScheduledEventEntityType.External,
|
||||
].includes(options.entityType)
|
||||
ScheduledEventEntityType.StageInstance,
|
||||
ScheduledEventEntityType.Voice,
|
||||
ScheduledEventEntityType.External,
|
||||
].includes(options.entityType)
|
||||
? await bot.helpers.createChannel(guildId, {
|
||||
name: "entity",
|
||||
type:
|
||||
options.entityType === ScheduledEventEntityType.Voice
|
||||
? ChannelTypes.GuildVoice
|
||||
: options.entityType === ScheduledEventEntityType.StageInstance
|
||||
? ChannelTypes.GuildStageVoice
|
||||
: ChannelTypes.GuildText,
|
||||
})
|
||||
name: "entity",
|
||||
type: options.entityType === ScheduledEventEntityType.Voice
|
||||
? ChannelTypes.GuildVoice
|
||||
: options.entityType === ScheduledEventEntityType.StageInstance
|
||||
? ChannelTypes.GuildStageVoice
|
||||
: ChannelTypes.GuildText,
|
||||
})
|
||||
: undefined;
|
||||
|
||||
if (channel && options.entityType !== ScheduledEventEntityType.External) options.channelId = channel.id;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { ChannelTypes } from "../../../../src/types/channels/channelTypes.ts";
|
||||
import {
|
||||
ScheduledEventEntityType,
|
||||
ScheduledEventPrivacyLevel,
|
||||
} from "../../../../src/types/guilds/scheduledEvents.ts";
|
||||
import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../../../src/types/guilds/scheduledEvents.ts";
|
||||
import { assertEquals } from "../../../deps.ts";
|
||||
import { bot } from "../../../mod.ts";
|
||||
|
||||
|
||||
@@ -3,16 +3,11 @@ import { CreateGuildBan } from "../../../src/types/mod.ts";
|
||||
import { assertEquals } from "../../deps.ts";
|
||||
import { delayUntil } from "../../utils.ts";
|
||||
|
||||
|
||||
|
||||
export async function banTest(bot: Bot, t: Deno.TestContext, guildId: bigint, id: bigint, options?: CreateGuildBan) {
|
||||
|
||||
}
|
||||
|
||||
export async function getBansTest(bot: Bot, t: Deno.TestContext, guildId: bigint) {
|
||||
|
||||
}
|
||||
|
||||
export async function unbanTest(bot: Bot, t: Deno.TestContext, guildId: bigint, id: bigint) {
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { bot } from "../../mod.ts";
|
||||
import { delayUntil } from "../../utils.ts";
|
||||
|
||||
export async function editMessageTest(channelId: bigint) {
|
||||
const message = await bot.helpers.sendMessage(channelId, { content: "Hello World!"});
|
||||
const message = await bot.helpers.sendMessage(channelId, { content: "Hello World!" });
|
||||
|
||||
// Assertions
|
||||
assertExists(message);
|
||||
@@ -15,7 +15,7 @@ export async function editMessageTest(channelId: bigint) {
|
||||
}
|
||||
|
||||
// Edit the message
|
||||
await bot.helpers.editMessage(channelId, message.id, {content: "Goodbye World!"});
|
||||
await bot.helpers.editMessage(channelId, message.id, { content: "Goodbye World!" });
|
||||
|
||||
// Wait to give it time for MESSAGE_UPDATE event
|
||||
// await delayUntil(10000, async () => bot.messages.get(message.id)?.content === "Goodbye World!");
|
||||
|
||||
@@ -4,8 +4,8 @@ import { delayUntil } from "../../utils.ts";
|
||||
|
||||
export async function getMessagesTest(channelId: bigint) {
|
||||
const message = await bot.helpers.sendMessage(channelId, { content: "Hello World!" });
|
||||
const secondMessage = await bot.helpers.sendMessage(channelId, {content: "Hello World 2!"});
|
||||
const thirdMessage = await bot.helpers.sendMessage(channelId, {content: "Hello World 3!"});
|
||||
const secondMessage = await bot.helpers.sendMessage(channelId, { content: "Hello World 2!" });
|
||||
const thirdMessage = await bot.helpers.sendMessage(channelId, { content: "Hello World 3!" });
|
||||
|
||||
// Assertions
|
||||
assertExists(message);
|
||||
@@ -14,7 +14,7 @@ export async function getMessagesTest(channelId: bigint) {
|
||||
// Delay the execution by to allow MESSAGE_CREATE event to be processed
|
||||
await delayUntil(
|
||||
10000,
|
||||
() => bot.messages.has(message.id) && bot.messages.has(secondMessage.id) && bot.messages.has(thirdMessage.id)
|
||||
() => bot.messages.has(message.id) && bot.messages.has(secondMessage.id) && bot.messages.has(thirdMessage.id),
|
||||
);
|
||||
// Make sure the messages was created.
|
||||
if (!bot.messages.has(message.id) || !bot.messages.has(secondMessage.id) || !bot.messages.has(thirdMessage.id)) {
|
||||
|
||||
@@ -8,7 +8,7 @@ const reactionCounters = new Map<bigint, number>();
|
||||
export async function addReactionTest(
|
||||
guildId: bigint,
|
||||
channelId: bigint,
|
||||
options: { custom: boolean; single: boolean; ordered: boolean }
|
||||
options: { custom: boolean; single: boolean; ordered: boolean },
|
||||
) {
|
||||
const message = await bot.helpers.sendMessage(channelId, { content: "Hello World!" });
|
||||
|
||||
|
||||
@@ -2,5 +2,4 @@ import { Bot } from "../../../src/bot.ts";
|
||||
import { assertExists } from "../../deps.ts";
|
||||
|
||||
export async function getUserTests() {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assertExists, assertEquals } from "../../deps.ts";
|
||||
import { assertEquals, assertExists } from "../../deps.ts";
|
||||
import { bot } from "../../mod.ts";
|
||||
import { CACHED_COMMUNITY_GUILD_ID } from "../../constants.ts";
|
||||
|
||||
@@ -29,7 +29,7 @@ Deno.test({
|
||||
name: "test",
|
||||
description: "Test slash command from the ddeno unit tests",
|
||||
},
|
||||
CACHED_COMMUNITY_GUILD_ID
|
||||
CACHED_COMMUNITY_GUILD_ID,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assertExists, assertEquals, assertNotEquals } from "../deps.ts";
|
||||
import { assertEquals, assertExists, assertNotEquals } from "../deps.ts";
|
||||
import { bot, channel, guild } from "../mod.ts";
|
||||
|
||||
Deno.test({
|
||||
|
||||
+10
-10
@@ -2,13 +2,13 @@ import { assertEquals } from "../deps.ts";
|
||||
import { bot } from "../mod.ts";
|
||||
|
||||
Deno.test({
|
||||
name: "[member] format a members avatar url",
|
||||
fn: async (t) => {
|
||||
assertEquals(
|
||||
bot.helpers.avatarURL(130136895395987456n, 8840, {
|
||||
avatar: 4055337350987360625717955448021200177333n,
|
||||
}),
|
||||
"https://cdn.discordapp.com/avatars/130136895395987456/eae5905ad2d18d7c8deca20478b088b5.jpg?size=128"
|
||||
);
|
||||
},
|
||||
});
|
||||
name: "[member] format a members avatar url",
|
||||
fn: async (t) => {
|
||||
assertEquals(
|
||||
bot.helpers.avatarURL(130136895395987456n, 8840, {
|
||||
avatar: 4055337350987360625717955448021200177333n,
|
||||
}),
|
||||
"https://cdn.discordapp.com/avatars/130136895395987456/eae5905ad2d18d7c8deca20478b088b5.jpg?size=128",
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
+10
-14
@@ -1,5 +1,5 @@
|
||||
import { banCounters } from "../constants.ts";
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot, guild } from "../mod.ts";
|
||||
import { delayUntil } from "../utils.ts";
|
||||
|
||||
@@ -40,11 +40,11 @@ Deno.test({
|
||||
bot.events.guildBanAdd = function (_, user) {
|
||||
banCounters.set(user.id, true);
|
||||
};
|
||||
|
||||
|
||||
await bot.helpers.banMember(guild.id, ianID, { reason: "Blame Wolf" });
|
||||
|
||||
|
||||
await delayUntil(10000, () => banCounters.get(ianID));
|
||||
|
||||
|
||||
assertEquals(banCounters.get(wolfID), true);
|
||||
},
|
||||
});
|
||||
@@ -56,7 +56,7 @@ Deno.test({
|
||||
assertEquals(bans.size > 1, true);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
await t.step({
|
||||
name: "[member] fetch a single member by id",
|
||||
fn: async () => {
|
||||
@@ -64,30 +64,26 @@ Deno.test({
|
||||
userIds: [bot.id],
|
||||
limit: 1,
|
||||
});
|
||||
|
||||
|
||||
// Assertions
|
||||
assertExists(bot.members.get(BigInt(`${bot.id}${guild.id}`)));
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
await t.step({
|
||||
name: "[member] unban member from guild",
|
||||
fn: async () => {
|
||||
bot.events.guildBanRemove = function (bot, user, guildId) {
|
||||
banCounters.set(user.id, false);
|
||||
};
|
||||
|
||||
|
||||
await Promise.all([bot.helpers.unbanMember(guild.id, wolfID), bot.helpers.unbanMember(guild.id, ianID)]);
|
||||
|
||||
|
||||
await delayUntil(10000, () => !banCounters.get(wolfID) && !banCounters.get(ianID));
|
||||
|
||||
|
||||
assertEquals(banCounters.get(wolfID), false);
|
||||
assertEquals(banCounters.get(ianID), false);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@ import { bot } from "../mod.ts";
|
||||
Deno.test("[member] get dm channel and send a message", async () => {
|
||||
// Itoh Alt ID
|
||||
const channel = await bot.helpers.getDmChannel(750661528360845322n);
|
||||
await bot.helpers.sendMessage(channel.id, {content: "https://i.imgur.com/doG55NR.png"});
|
||||
await bot.helpers.sendMessage(channel.id, { content: "https://i.imgur.com/doG55NR.png" });
|
||||
});
|
||||
|
||||
@@ -2,6 +2,6 @@ import { bot, guild } from "../mod.ts";
|
||||
import { assertEquals } from "../deps.ts";
|
||||
|
||||
Deno.test("[member] fetches the bot and compares the bot's id with the fetched member's id", async () => {
|
||||
const member = await bot.helpers.getMember(guild.id,bot.id);
|
||||
assertEquals(member.id, bot.id);
|
||||
const member = await bot.helpers.getMember(guild.id, bot.id);
|
||||
assertEquals(member.id, bot.id);
|
||||
});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Bot } from "../../mod.ts";
|
||||
import { reactionCounters } from "../constants.ts";
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
// import {
|
||||
// addReactionTest,
|
||||
// removeReactionTest,
|
||||
// removeAllReactionTests,
|
||||
// removeReactionEmojiTest,
|
||||
// } from "../helpers/messages/reactions.ts";
|
||||
import { bot, guild, channel } from "../mod.ts";
|
||||
import { bot, channel, guild } from "../mod.ts";
|
||||
import { delayUntil } from "../utils.ts";
|
||||
|
||||
export async function addReactionTest(
|
||||
|
||||
@@ -5,20 +5,20 @@ import { delayUntil } from "../utils.ts";
|
||||
|
||||
Deno.test("[misc] edit the bot's status", async function () {
|
||||
bot.events.presenceUpdate = function (_bot, presense, _oldPresense) {
|
||||
console.log('in pu')
|
||||
console.log('in pu')
|
||||
console.log("in pu");
|
||||
console.log("in pu");
|
||||
assertExists(presense);
|
||||
};
|
||||
|
||||
bot.events.botUpdate = function (bot, user) {
|
||||
console.log('in bu')
|
||||
console.log('in bu')
|
||||
}
|
||||
|
||||
console.log("in bu");
|
||||
console.log("in bu");
|
||||
};
|
||||
|
||||
bot.helpers.editBotStatus({
|
||||
status: "dnd",
|
||||
activities: [{ name: "lts20050703", type: ActivityTypes.Game, createdAt: Date.now() }],
|
||||
});
|
||||
|
||||
await delayUntil(10000, () => false)
|
||||
await delayUntil(10000, () => false);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot } from "../mod.ts";
|
||||
|
||||
Deno.test({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { bot, guild } from '../mod.ts';
|
||||
import { bot, guild } from "../mod.ts";
|
||||
|
||||
Deno.test("[typing] start typing", async () => {
|
||||
const channel = await bot.helpers.createChannel(guild.id, { name: "typing"})
|
||||
await bot.helpers.startTyping(channel.id)
|
||||
})
|
||||
const channel = await bot.helpers.createChannel(guild.id, { name: "typing" });
|
||||
await bot.helpers.startTyping(channel.id);
|
||||
});
|
||||
|
||||
+2
-4
@@ -1,7 +1,7 @@
|
||||
import { UNITTEST_TOKEN } from "../configs.ts";
|
||||
import { createBot, createEventHandlers, ChannelTypes, startBot } from "../mod.ts";
|
||||
import { ChannelTypes, createBot, createEventHandlers, startBot } from "../mod.ts";
|
||||
import { assertEquals, assertExists, enableCachePlugin } from "./deps.ts";
|
||||
import { deleteMessageWithReasonTest, deleteMessageWithoutReasonTest } from "./helpers/messages/deleteMessage.ts";
|
||||
import { deleteMessageWithoutReasonTest, deleteMessageWithReasonTest } from "./helpers/messages/deleteMessage.ts";
|
||||
import { getMessagesTest } from "./helpers/messages/getMessages.ts";
|
||||
import { deleteMessagesWithoutReasonTest, deleteMessagesWithReasonTest } from "./helpers/messages/deleteMessages.ts";
|
||||
import { delayUntil } from "./utils.ts";
|
||||
@@ -254,7 +254,6 @@ Deno.test({
|
||||
...sanitizeMode,
|
||||
});
|
||||
|
||||
|
||||
Deno.test({
|
||||
name: "[channel] filter all category channels",
|
||||
async fn(t) {
|
||||
@@ -357,4 +356,3 @@ import "./webhooks/deleteWebhook.ts";
|
||||
import "./webhooks/deleteWebhookWithToken.ts";
|
||||
import "./webhooks/sendWebhook.ts";
|
||||
import "./webhooks/webhooks.ts";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { roleChanges } from "../constants.ts";
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot, guild } from "../mod.ts";
|
||||
import { delayUntil } from "../utils.ts";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot, guild } from "../mod.ts";
|
||||
import { delayUntil } from "../utils.ts";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { roleChanges } from "../constants.ts";
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot, guild } from "../mod.ts";
|
||||
import { delayUntil } from "../utils.ts";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ScheduledEventPrivacyLevel, ScheduledEventEntityType } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot, guild } from "../mod.ts";
|
||||
|
||||
Deno.test({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ScheduledEventPrivacyLevel, ScheduledEventEntityType } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot, guild } from "../mod.ts";
|
||||
|
||||
Deno.test({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ChannelTypes } from "../../mod.ts";
|
||||
import { ScheduledEventPrivacyLevel, ScheduledEventEntityType } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { CACHED_COMMUNITY_GUILD_ID } from "../constants.ts";
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot } from "../mod.ts";
|
||||
|
||||
Deno.test({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ChannelTypes } from "../../mod.ts";
|
||||
import { ScheduledEventPrivacyLevel, ScheduledEventEntityType } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { CACHED_COMMUNITY_GUILD_ID } from "../constants.ts";
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot } from "../mod.ts";
|
||||
|
||||
Deno.test({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ChannelTypes } from "../../mod.ts";
|
||||
import { ScheduledEventPrivacyLevel, ScheduledEventEntityType } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot, guild } from "../mod.ts";
|
||||
|
||||
Deno.test({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ChannelTypes } from "../../mod.ts";
|
||||
import { ScheduledEventPrivacyLevel, ScheduledEventEntityType } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { assertExists, assertEquals } from "../deps.ts";
|
||||
import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { bot, guild } from "../mod.ts";
|
||||
|
||||
Deno.test({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ScheduledEventPrivacyLevel, ScheduledEventEntityType } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { bot, guild } from "../mod.ts";
|
||||
|
||||
Deno.test({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ChannelTypes } from "../../mod.ts";
|
||||
import { ScheduledEventPrivacyLevel, ScheduledEventEntityType } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../src/types/guilds/scheduledEvents.ts";
|
||||
import { CACHED_COMMUNITY_GUILD_ID } from "../constants.ts";
|
||||
import { assertEquals } from "../deps.ts";
|
||||
import { bot } from "../mod.ts";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { iconHashToBigInt, iconBigintToHash } from "../../src/util/hash.ts";
|
||||
import { iconBigintToHash, iconHashToBigInt } from "../../src/util/hash.ts";
|
||||
import { assertEquals } from "../deps.ts";
|
||||
const iconHash = "4bbb271a13f7195031adcc06a2d867ce";
|
||||
const iconBigInt = 3843769888406823508519992434416504301518n;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { hasProperty, delay } from "../../src/util/utils.ts";
|
||||
import { delay, hasProperty } from "../../src/util/utils.ts";
|
||||
import { assertEquals } from "../deps.ts";
|
||||
|
||||
// hasProperty
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
export function delayUntil(
|
||||
maxMs: number,
|
||||
isReady: () => boolean | undefined | Promise<boolean | undefined>,
|
||||
timeoutTime = 100
|
||||
timeoutTime = 100,
|
||||
): Promise<void> {
|
||||
const maxTime = Date.now() + maxMs;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user