Prettified Code!

This commit is contained in:
itohatweb
2021-05-21 15:51:33 +00:00
committed by GitHub Action
parent fe4ab8517b
commit 3549cdeb63
279 changed files with 1617 additions and 1768 deletions
+6 -7
View File
@@ -21,7 +21,7 @@ Deno.test({
if (!cache.channels.has(category.id)) {
throw new Error(
"The channel seemed to be created but it was not cached.",
"The channel seemed to be created but it was not cached."
);
}
@@ -32,18 +32,17 @@ Deno.test({
name: `Discordeno-test-${num}`,
parentId: bigintToSnowflake(category.id),
})
),
)
);
// Delay the execution by 5 seconds to allow CHANNEL_CREATE event to be processed
await delayUntil(
10000,
() => channels.every((c) => cache.channels.has(c.id)),
await delayUntil(10000, () =>
channels.every((c) => cache.channels.has(c.id))
);
// If every channel is not present in the cache, error out
if (!channels.every((c) => cache.channels.has(c.id))) {
throw new Error(
"The channels seemed to be created but it was not cached.",
"The channels seemed to be created but it was not cached."
);
}
@@ -53,7 +52,7 @@ Deno.test({
!channels.every((c) => ids.has(c.id))
) {
throw new Error(
"The category channel ids did not match with the category channels.",
"The category channel ids did not match with the category channels."
);
}
},
@@ -29,7 +29,7 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel) {
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."
);
}
@@ -38,28 +38,26 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel) {
channel.guildId,
botId,
cache.channels.get(channel.id)?.permissionOverwrites || [],
options.permissionOverwrites ? options.permissionOverwrites[0].allow : [],
options.permissionOverwrites ? options.permissionOverwrites[0].allow : []
),
true,
true
);
}
Deno.test({
name: "[channel] edit channel permission overwrites",
async fn() {
await ifItFailsBlameWolf(
{
name: "Discordeno-test",
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
],
},
);
await ifItFailsBlameWolf({
name: "Discordeno-test",
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
],
});
},
...defaultTestOptions,
});
+64 -81
View File
@@ -13,7 +13,7 @@ import { defaultTestOptions, tempData } from "../ws/start_bot.ts";
async function ifItFailsBlameWolf(
options: CreateGuildChannel,
useGetter = false,
reason?: string,
reason?: string
) {
const channel = await createChannel(tempData.guildId, options);
@@ -34,13 +34,13 @@ async function ifItFailsBlameWolf(
if (channel.topic && cloned.topic !== channel.topic) {
throw new Error(
"The clone was supposed to have a topic but it does not appear to be the same topic.",
"The clone was supposed to have a topic but it does not appear to be the same topic."
);
}
if (channel.bitrate && cloned.bitrate !== channel.bitrate) {
throw new Error(
"The clone was supposed to have a bitrate but it does not appear to be the same bitrate.",
"The clone was supposed to have a bitrate but it does not appear to be the same bitrate."
);
}
@@ -49,7 +49,7 @@ async function ifItFailsBlameWolf(
cloned.permissionOverwrites?.length !== channel.permissionOverwrites.length
) {
throw new Error(
"The clone was supposed to have a permissionOverwrites but it does not appear to be the same permissionOverwrites.",
"The clone was supposed to have a permissionOverwrites but it does not appear to be the same permissionOverwrites."
);
}
}
@@ -68,7 +68,7 @@ Deno.test({
await ifItFailsBlameWolf(
{ name: "Discordeno-clone-test" },
false,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -77,12 +77,10 @@ Deno.test({
Deno.test({
name: "[channel] clone a new category channel",
async fn() {
await ifItFailsBlameWolf(
{
name: "Discordeno-clone-test",
type: DiscordChannelTypes.GuildCategory,
},
);
await ifItFailsBlameWolf({
name: "Discordeno-clone-test",
type: DiscordChannelTypes.GuildCategory,
});
},
...defaultTestOptions,
});
@@ -96,7 +94,7 @@ Deno.test({
type: DiscordChannelTypes.GuildCategory,
},
false,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -105,12 +103,10 @@ Deno.test({
Deno.test({
name: "[channel] clone a new voice channel",
async fn() {
await ifItFailsBlameWolf(
{
name: "Discordeno-clone-test",
type: DiscordChannelTypes.GuildVoice,
},
);
await ifItFailsBlameWolf({
name: "Discordeno-clone-test",
type: DiscordChannelTypes.GuildVoice,
});
},
...defaultTestOptions,
});
@@ -124,7 +120,7 @@ Deno.test({
type: DiscordChannelTypes.GuildVoice,
},
false,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -133,13 +129,11 @@ Deno.test({
Deno.test({
name: "[channel] clone a new voice channel with a bitrate",
async fn() {
await ifItFailsBlameWolf(
{
name: "discordeno-clone-test",
type: DiscordChannelTypes.GuildVoice,
bitrate: 32000,
},
);
await ifItFailsBlameWolf({
name: "discordeno-clone-test",
type: DiscordChannelTypes.GuildVoice,
bitrate: 32000,
});
},
...defaultTestOptions,
});
@@ -154,7 +148,7 @@ Deno.test({
bitrate: 32000,
},
false,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -163,13 +157,11 @@ Deno.test({
Deno.test({
name: "[channel] clone a new voice channel with a user limit",
async fn() {
await ifItFailsBlameWolf(
{
name: "Discordeno-clone-test",
type: DiscordChannelTypes.GuildVoice,
userLimit: 32,
},
);
await ifItFailsBlameWolf({
name: "Discordeno-clone-test",
type: DiscordChannelTypes.GuildVoice,
userLimit: 32,
});
},
...defaultTestOptions,
});
@@ -184,7 +176,7 @@ Deno.test({
userLimit: 32,
},
false,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -193,19 +185,16 @@ Deno.test({
Deno.test({
name: "[channel] clone a new text channel with a rate limit per user",
async fn() {
await ifItFailsBlameWolf(
{
name: "Discordeno-clone-test",
rateLimitPerUser: 2423,
},
);
await ifItFailsBlameWolf({
name: "Discordeno-clone-test",
rateLimitPerUser: 2423,
});
},
...defaultTestOptions,
});
Deno.test({
name:
"[channel] clone a new text channel with a rate limit per user w/reason",
name: "[channel] clone a new text channel with a rate limit per user w/reason",
async fn() {
await ifItFailsBlameWolf(
{
@@ -213,7 +202,7 @@ Deno.test({
rateLimitPerUser: 2423,
},
false,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -222,9 +211,7 @@ Deno.test({
Deno.test({
name: "[channel] clone a new text channel with NSFW",
async fn() {
await ifItFailsBlameWolf(
{ name: "Discordeno-clone-test", nsfw: true },
);
await ifItFailsBlameWolf({ name: "Discordeno-clone-test", nsfw: true });
},
...defaultTestOptions,
});
@@ -235,7 +222,7 @@ Deno.test({
await ifItFailsBlameWolf(
{ name: "Discordeno-clone-test", nsfw: true },
false,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -244,19 +231,17 @@ Deno.test({
Deno.test({
name: "[channel] clone a new text channel with permission overwrites",
async fn() {
await ifItFailsBlameWolf(
{
name: "Discordeno-clone-test",
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
],
},
);
await ifItFailsBlameWolf({
name: "Discordeno-clone-test",
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
],
});
},
...defaultTestOptions,
});
@@ -277,7 +262,7 @@ Deno.test({
],
},
false,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -299,7 +284,7 @@ Deno.test({
await ifItFailsBlameWolf(
{ name: "Discordeno-clone-test" },
true,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -313,7 +298,7 @@ Deno.test({
name: "Discordeno-clone-test",
type: DiscordChannelTypes.GuildCategory,
},
true,
true
);
},
...defaultTestOptions,
@@ -328,7 +313,7 @@ Deno.test({
type: DiscordChannelTypes.GuildCategory,
},
true,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -342,7 +327,7 @@ Deno.test({
name: "Discordeno-clone-test",
type: DiscordChannelTypes.GuildVoice,
},
true,
true
);
},
...defaultTestOptions,
@@ -357,7 +342,7 @@ Deno.test({
type: DiscordChannelTypes.GuildVoice,
},
true,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -372,7 +357,7 @@ Deno.test({
type: DiscordChannelTypes.GuildVoice,
bitrate: 32000,
},
true,
true
);
},
...defaultTestOptions,
@@ -388,7 +373,7 @@ Deno.test({
bitrate: 32000,
},
true,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -403,7 +388,7 @@ Deno.test({
type: DiscordChannelTypes.GuildVoice,
userLimit: 32,
},
true,
true
);
},
...defaultTestOptions,
@@ -419,7 +404,7 @@ Deno.test({
userLimit: 32,
},
true,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -433,15 +418,14 @@ Deno.test({
name: "Discordeno-clone-test",
rateLimitPerUser: 2423,
},
true,
true
);
},
...defaultTestOptions,
});
Deno.test({
name:
"[channel] clone() a new text channel with a rate limit per user w/reason",
name: "[channel] clone() a new text channel with a rate limit per user w/reason",
async fn() {
await ifItFailsBlameWolf(
{
@@ -449,7 +433,7 @@ Deno.test({
rateLimitPerUser: 2423,
},
true,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -460,7 +444,7 @@ Deno.test({
async fn() {
await ifItFailsBlameWolf(
{ name: "Discordeno-clone-test", nsfw: true },
true,
true
);
},
...defaultTestOptions,
@@ -472,7 +456,7 @@ Deno.test({
await ifItFailsBlameWolf(
{ name: "Discordeno-clone-test", nsfw: true },
true,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
@@ -493,15 +477,14 @@ Deno.test({
},
],
},
true,
true
);
},
...defaultTestOptions,
});
Deno.test({
name:
"[channel] clone() a new text channel with permission overwrites w/reason",
name: "[channel] clone() a new text channel with permission overwrites w/reason",
async fn() {
await ifItFailsBlameWolf(
{
@@ -516,7 +499,7 @@ Deno.test({
],
},
true,
"w/reason",
"w/reason"
);
},
...defaultTestOptions,
+9 -9
View File
@@ -27,13 +27,13 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel, save = false) {
if (options.topic && channel.topic !== options.topic) {
throw new Error(
"The channel was supposed to have a topic but it does not appear to be the same topic.",
"The channel was supposed to have a topic but it does not appear to be the same topic."
);
}
if (options.bitrate && channel.bitrate !== options.bitrate) {
throw new Error(
"The channel was supposed to have a bitrate but it does not appear to be the same bitrate.",
"The channel was supposed to have a bitrate but it does not appear to be the same bitrate."
);
}
@@ -42,7 +42,7 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel, save = false) {
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."
);
}
}
@@ -63,7 +63,7 @@ Deno.test({
name: "Discordeno-test",
type: DiscordChannelTypes.GuildCategory,
},
true,
true
);
},
...defaultTestOptions,
@@ -93,7 +93,7 @@ Deno.test({
name: "Discordeno-test",
type: DiscordChannelTypes.GuildVoice,
},
true,
true
);
},
...defaultTestOptions,
@@ -108,7 +108,7 @@ Deno.test({
type: DiscordChannelTypes.GuildVoice,
bitrate: 32000,
},
true,
true
);
},
...defaultTestOptions,
@@ -123,7 +123,7 @@ Deno.test({
type: DiscordChannelTypes.GuildVoice,
userLimit: 32,
},
true,
true
);
},
...defaultTestOptions,
@@ -137,7 +137,7 @@ Deno.test({
name: "Discordeno-test",
rateLimitPerUser: 2423,
},
true,
true
);
},
...defaultTestOptions,
@@ -166,7 +166,7 @@ Deno.test({
},
],
},
true,
true
);
},
...defaultTestOptions,
+4 -4
View File
@@ -16,7 +16,7 @@ Deno.test({
// Make sure the channel was created.
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel should have been created but it is not in the cache.",
"The channel should have been created but it is not in the cache."
);
}
@@ -27,7 +27,7 @@ Deno.test({
// Make sure it is gone from cache
if (cache.channels.has(channel.id)) {
throw new Error(
"The channel should have been deleted but it is still in cache.",
"The channel should have been deleted but it is still in cache."
);
}
},
@@ -46,7 +46,7 @@ Deno.test({
// Make sure the channel was created.
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel should have been created but it is not in the cache.",
"The channel should have been created but it is not in the cache."
);
}
@@ -57,7 +57,7 @@ Deno.test({
// Make sure it is gone from cache
if (cache.channels.has(channel.id)) {
throw new Error(
"The channel should have been deleted but it is still in cache.",
"The channel should have been deleted but it is still in cache."
);
}
},
+4 -4
View File
@@ -29,7 +29,7 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel, _save = false) {
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."
);
}
@@ -37,12 +37,12 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel, _save = false) {
await delayUntil(
10000,
() => cache.channels.get(channel.id)?.permissionOverwrites?.length === 0,
() => cache.channels.get(channel.id)?.permissionOverwrites?.length === 0
);
if (cache.channels.get(channel.id)?.permissionOverwrites?.length !== 0) {
throw new Error(
"The channel permission overwrite was supposed to be deleted but it does not appear to be.",
"The channel permission overwrite was supposed to be deleted but it does not appear to be."
);
}
}
@@ -62,7 +62,7 @@ Deno.test({
},
],
},
true,
true
);
},
...defaultTestOptions,
+9 -5
View File
@@ -15,15 +15,19 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", reason?: string) {
// Make sure the channel was created.
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel should have been created but it is not in the cache.",
"The channel should have been created but it is not in the cache."
);
}
// Edit the channel now
if (type === "raw") {
await editChannel(channel.id, {
name: "new-name",
}, reason);
await editChannel(
channel.id,
{
name: "new-name",
},
reason
);
} else {
await channel.edit({
name: "new-name",
@@ -32,7 +36,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", reason?: string) {
// wait 5 seconds to give it time for CHANNEL_UPDATE event
await delayUntil(
3000,
() => cache.channels.get(channel.id)?.name === "new-name",
() => cache.channels.get(channel.id)?.name === "new-name"
);
assertEquals(cache.channels.get(channel.id)?.name, "new-name");
}
+21 -25
View File
@@ -30,7 +30,7 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel) {
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."
);
}
@@ -40,15 +40,13 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel) {
deny: [],
});
await delayUntil(
10000,
() =>
channelOverwriteHasPermission(
channel.guildId,
botId,
cache.channels.get(channel.id)?.permissionOverwrites || [],
["VIEW_CHANNEL", "ADD_REACTIONS"],
),
await delayUntil(10000, () =>
channelOverwriteHasPermission(
channel.guildId,
botId,
cache.channels.get(channel.id)?.permissionOverwrites || [],
["VIEW_CHANNEL", "ADD_REACTIONS"]
)
);
assertEquals(
@@ -56,28 +54,26 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel) {
channel.guildId,
botId,
cache.channels.get(channel.id)?.permissionOverwrites || [],
["VIEW_CHANNEL", "ADD_REACTIONS"],
["VIEW_CHANNEL", "ADD_REACTIONS"]
),
true,
true
);
}
Deno.test({
name: "[channel] edit channel permission overwrites",
async fn() {
await ifItFailsBlameWolf(
{
name: "Discordeno-test",
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
],
},
);
await ifItFailsBlameWolf({
name: "Discordeno-test",
permissionOverwrites: [
{
id: bigintToSnowflake(botId),
type: DiscordOverwriteTypes.Member,
allow: ["VIEW_CHANNEL"],
deny: [],
},
],
});
},
...defaultTestOptions,
});
+2 -5
View File
@@ -17,7 +17,7 @@ Deno.test({
// Make sure the channel was created.
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel should have been created but it is not in the cache.",
"The channel should have been created but it is not in the cache."
);
}
@@ -27,10 +27,7 @@ Deno.test({
await getChannel(channel.id);
await delayUntil(3000, () => cache.channels.has(channel.id));
assertEquals(
cache.channels.has(channel.id),
true,
);
assertEquals(cache.channels.has(channel.id), true);
},
...defaultTestOptions,
});
+1 -4
View File
@@ -13,10 +13,7 @@ Deno.test({
await getChannels(tempData.guildId);
await delayUntil(3000, () => cache.channels.size > 0);
assertEquals(
cache.channels.size > 0,
true,
);
assertEquals(cache.channels.size > 0, true);
},
...defaultTestOptions,
});
+4 -7
View File
@@ -21,21 +21,21 @@ Deno.test({
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel seemed to be created but it was not cached.",
"The channel seemed to be created but it was not cached."
);
}
const message = await sendMessage(tempData.channelId, "Hello World!");
const secondMessage = await sendMessage(
tempData.channelId,
"Goodbye World!",
"Goodbye World!"
);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delayUntil(
10000,
() =>
cache.messages.has(message.id) && cache.messages.has(secondMessage.id),
cache.messages.has(message.id) && cache.messages.has(secondMessage.id)
);
await message.pin();
@@ -43,10 +43,7 @@ Deno.test({
const pins = await getPins(tempData.channelId);
assertEquals(
pins.length,
2,
);
assertEquals(pins.length, 2);
},
...defaultTestOptions,
});
+3 -6
View File
@@ -33,7 +33,7 @@ Deno.test({
if (!cache.channels.has(category.id)) {
throw new Error(
"The channel seemed to be created but it was not cached.",
"The channel seemed to be created but it was not cached."
);
}
@@ -50,16 +50,13 @@ Deno.test({
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel seemed to be created but it was not cached.",
"The channel seemed to be created but it was not cached."
);
}
const isSynced = await isChannelSynced(channel.id);
assertEquals(
isSynced,
true,
);
assertEquals(isSynced, true);
},
...defaultTestOptions,
});
+1 -1
View File
@@ -20,7 +20,7 @@ Deno.test({
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel seemed to be created but it was not cached.",
"The channel seemed to be created but it was not cached."
);
}
+7 -6
View File
@@ -26,14 +26,15 @@ Deno.test({
await delayUntil(
10000,
() =>
cache.channels.has(channel.id) && cache.channels.has(secondChannel.id),
cache.channels.has(channel.id) && cache.channels.has(secondChannel.id)
);
if (
!cache.channels.has(channel.id) || !cache.channels.has(secondChannel.id)
!cache.channels.has(channel.id) ||
!cache.channels.has(secondChannel.id)
) {
throw new Error(
"The channel seemed to be created but it was not cached.",
"The channel seemed to be created but it was not cached."
);
}
@@ -53,17 +54,17 @@ Deno.test({
10000,
() =>
cache.channels.get(channel.id)?.position === secondChannel.position &&
cache.channels.get(secondChannel.id)?.position === channel.position,
cache.channels.get(secondChannel.id)?.position === channel.position
);
assertEquals(
cache.channels.get(channel.id)?.position,
secondChannel.position,
secondChannel.position
);
assertEquals(
cache.channels.get(secondChannel.id)?.position,
channel.position,
channel.position
);
},
...defaultTestOptions,
@@ -7,10 +7,7 @@ Deno.test({
async fn() {
const categories = await getDiscoveryCategories();
assertEquals(
categories.size > 0,
true,
);
assertEquals(categories.size > 0, true);
},
...defaultTestOptions,
});
+1 -4
View File
@@ -7,10 +7,7 @@ Deno.test({
async fn() {
const valid = await validDiscoveryTerm("Bots");
assertEquals(
valid,
true,
);
assertEquals(valid, true);
},
...defaultTestOptions,
});
+4 -5
View File
@@ -15,19 +15,18 @@ Deno.test({
name: "blamewolf",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
},
}
);
assertExists(emoji);
await delayUntil(
10000,
() => cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!),
await delayUntil(10000, () =>
cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!)
);
assertEquals(
cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!),
true,
true
);
},
...defaultTestOptions,
+5 -6
View File
@@ -14,26 +14,25 @@ async function ifItFailsBlameWolf(reason?: string) {
name: "blamewolf",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
},
}
);
assertExists(emoji);
await delayUntil(
10000,
() => cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!),
await delayUntil(10000, () =>
cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!)
);
await deleteEmoji(tempData.guildId, emoji.id!, reason);
await delayUntil(
10000,
() => !cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!),
() => !cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!)
);
assertEquals(
cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!),
false,
false
);
}
+5 -6
View File
@@ -16,14 +16,13 @@ Deno.test({
name: "blamewolf",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
},
}
);
assertExists(emoji);
await delayUntil(
10000,
() => cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!),
await delayUntil(10000, () =>
cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!)
);
await editEmoji(tempData.guildId, emoji.id!, {
@@ -34,12 +33,12 @@ Deno.test({
10000,
() =>
cache.guilds.get(tempData.guildId)?.emojis?.get(emoji.id!)?.name ===
"blamewolf_infinite",
"blamewolf_infinite"
);
assertEquals(
cache.guilds.get(tempData.guildId)?.emojis?.get(emoji.id!)?.name,
"blamewolf_infinite",
"blamewolf_infinite"
);
},
...defaultTestOptions,
+6 -8
View File
@@ -16,28 +16,26 @@ Deno.test({
name: "blamewolf",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
},
}
);
assertExists(emoji);
await delayUntil(
10000,
() => cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!),
await delayUntil(10000, () =>
cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!)
);
cache.guilds.get(tempData.guildId)?.emojis?.delete(emoji.id!);
await getEmoji(tempData.guildId, emoji.id!);
await delayUntil(
10000,
() => cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!),
await delayUntil(10000, () =>
cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!)
);
assertEquals(
cache.guilds.get(tempData.guildId)?.emojis?.has(emoji.id!),
true,
true
);
},
...defaultTestOptions,
+2 -2
View File
@@ -13,12 +13,12 @@ Deno.test({
await delayUntil(
10000,
() => (cache.guilds.get(tempData.guildId)?.emojis?.size || 0) > 0,
() => (cache.guilds.get(tempData.guildId)?.emojis?.size || 0) > 0
);
assertEquals(
(cache.guilds.get(tempData.guildId)?.emojis?.size || 0) > 0,
true,
true
);
},
...defaultTestOptions,
+3 -3
View File
@@ -22,9 +22,9 @@ Deno.test({
if (!cache.guilds.has(guild.id)) {
throw new Error(
`The guild seemed to be created but it was not cached. ${
JSON.stringify(guild)
}`,
`The guild seemed to be created but it was not cached. ${JSON.stringify(
guild
)}`
);
}
},
+2 -5
View File
@@ -21,7 +21,7 @@ Deno.test({
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel seemed to be created but it was not cached.",
"The channel seemed to be created but it was not cached."
);
}
@@ -35,10 +35,7 @@ Deno.test({
// Assertions
assertExists(invite);
assertEquals(
await getInvite(invite.code) !== undefined,
true,
);
assertEquals((await getInvite(invite.code)) !== undefined, true);
},
...defaultTestOptions,
});
+2 -5
View File
@@ -22,7 +22,7 @@ Deno.test({
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel seemed to be created but it was not cached.",
"The channel seemed to be created but it was not cached."
);
}
@@ -38,10 +38,7 @@ Deno.test({
await deleteInvite(channel.id, invite.code);
assertEquals(
(await getChannelInvites(channel.id))?.size,
0,
);
assertEquals((await getChannelInvites(channel.id))?.size, 0);
},
...defaultTestOptions,
});
+2 -5
View File
@@ -21,7 +21,7 @@ Deno.test({
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel seemed to be created but it was not cached.",
"The channel seemed to be created but it was not cached."
);
}
@@ -45,10 +45,7 @@ Deno.test({
// Assertions
assertExists(secondInvite);
assertEquals(
(await getChannelInvites(channel.id))?.size,
2,
);
assertEquals((await getChannelInvites(channel.id))?.size, 2);
},
...defaultTestOptions,
});
+2 -5
View File
@@ -21,7 +21,7 @@ Deno.test({
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel seemed to be created but it was not cached.",
"The channel seemed to be created but it was not cached."
);
}
@@ -39,10 +39,7 @@ Deno.test({
assertExists(fetchedInvite);
assertEquals(
fetchedInvite.code,
invite.code,
);
assertEquals(fetchedInvite.code, invite.code);
},
...defaultTestOptions,
});
+1 -1
View File
@@ -14,7 +14,7 @@ async function ifItFailsBlameWolf() {
botMember!.username.substring(0, 4),
{
limit: 1,
},
}
);
assertEquals(foundMembers.size, 1);
+4 -4
View File
@@ -33,7 +33,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", custom = false) {
name: "blamewolf",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
},
}
)
).id
}>`;
@@ -47,7 +47,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", custom = false) {
await delayUntil(
10000,
() => cache.messages.get(message.id)?.reactions?.length === 1,
() => cache.messages.get(message.id)?.reactions?.length === 1
);
assertEquals(
@@ -55,9 +55,9 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", custom = false) {
.get(message.id)
?.reactions?.filter(
(reaction: Reaction) =>
reaction.emoji?.name === (custom ? "blamewolf" : "❤"),
reaction.emoji?.name === (custom ? "blamewolf" : "❤")
).length,
1,
1
);
}
+4 -4
View File
@@ -6,7 +6,7 @@ import { delayUntil } from "../util/delay_until.ts";
async function ifItFailsBlameWolf(
type: "getter" | "raw",
custom = false,
ordered = false,
ordered = false
) {
const message = await sendMessage(tempData.channelId, "Hello World!");
@@ -34,7 +34,7 @@ async function ifItFailsBlameWolf(
name: "blamewolf",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
},
}
)
).id
}>`,
@@ -48,7 +48,7 @@ async function ifItFailsBlameWolf(
name: "blamewolf2",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
},
}
)
).id
}>`,
@@ -63,7 +63,7 @@ async function ifItFailsBlameWolf(
await delayUntil(
10000,
() => cache.messages.get(message.id)?.reactions?.length === 2,
() => cache.messages.get(message.id)?.reactions?.length === 2
);
assertEquals(await cache.messages.get(message.id)?.reactions?.length, 2);
+7 -6
View File
@@ -6,7 +6,7 @@ import { defaultTestOptions, tempData } from "../ws/start_bot.ts";
async function ifItFailsBlameWolf(
type: "getter" | "raw",
content: "string" | "embed" | "reply" = "string",
content: "string" | "embed" | "reply" = "string"
) {
const channel = cache.channels.get(tempData.channelId);
assertExists(channel);
@@ -46,9 +46,10 @@ async function ifItFailsBlameWolf(
};
}
const message = type === "raw"
? await sendMessage(channel!.id, messageContent)
: await channel?.send(messageContent);
const message =
type === "raw"
? await sendMessage(channel!.id, messageContent)
: await channel?.send(messageContent);
// Assertions
assertExists(message);
@@ -67,7 +68,7 @@ async function ifItFailsBlameWolf(
} else {
assertEquals(
cache.messages.get(message!.id)?.messageReference?.messageId,
secondMessageId,
secondMessageId
);
}
}
@@ -140,7 +141,7 @@ Deno.test({
assertEquals(
cache.messages.get(reply.id)?.messageReference?.messageId,
message.id,
message.id
);
},
...defaultTestOptions,
+1 -1
View File
@@ -29,7 +29,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", reason?: string) {
// Make sure it is gone from cache
if (cache.messages.has(message.id)) {
throw new Error(
"The message should have been deleted but it is still in cache.",
"The message should have been deleted but it is still in cache."
);
}
}
+3 -3
View File
@@ -30,19 +30,19 @@ async function ifItFailsBlameWolf(reason?: string) {
await deleteMessages(
tempData.channelId,
[message.id, secondMessage.id],
reason,
reason
);
// Wait 5 seconds to give it time for MESSAGE_DELETE event
await delayUntil(
10000,
() =>
!cache.messages.has(message.id) && !cache.messages.has(secondMessage.id),
!cache.messages.has(message.id) && !cache.messages.has(secondMessage.id)
);
// Make sure it is gone from cache
if (cache.messages.has(message.id) || cache.messages.has(secondMessage.id)) {
throw new Error(
"The message should have been deleted but it is still in cache.",
"The message should have been deleted but it is still in cache."
);
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
// Wait 5 seconds to give it time for MESSAGE_UPDATE event
await delayUntil(
10000,
() => cache.messages.get(message.id)?.content === "Goodbye World!",
() => cache.messages.get(message.id)?.content === "Goodbye World!"
);
// Make sure it has been modified in cache
+3 -3
View File
@@ -9,11 +9,11 @@ Deno.test({
const message = await sendMessage(tempData.channelId, "Hello World!");
const secondMessage = await sendMessage(
tempData.channelId,
"Hello World 2!",
"Hello World 2!"
);
const thirdMessage = await sendMessage(
tempData.channelId,
"Hello World 3!",
"Hello World 3!"
);
// Assertions
@@ -26,7 +26,7 @@ Deno.test({
() =>
cache.messages.has(message.id) &&
cache.messages.has(secondMessage.id) &&
cache.messages.has(thirdMessage.id),
cache.messages.has(thirdMessage.id)
);
// Make sure the message was created.
if (
+1 -1
View File
@@ -23,7 +23,7 @@ Deno.test({
const fetchedReactions = await getReactions(
tempData.channelId,
message.id,
"❤",
"❤"
);
// Check if getMessage has worked
assertEquals(fetchedReactions.size, 1);
+1 -1
View File
@@ -26,7 +26,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
const pins = await getPins(tempData.channelId);
assertEquals(
pins.filter((msg: DiscordenoMessage) => msg.id === message.id).length,
1,
1
);
}
+2 -2
View File
@@ -25,7 +25,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_ALL event to be processed
await delayUntil(
10000,
() => cache.messages.get(message.id)?.reactions?.length === 3,
() => cache.messages.get(message.id)?.reactions?.length === 3
);
// Be sure that the message has the reactions
@@ -40,7 +40,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_REMOVE_ALL event to be processed
await delayUntil(
10000,
() => cache.messages.get(message.id)?.reactions === undefined,
() => cache.messages.get(message.id)?.reactions === undefined
);
// Check if the reactions has been deleted
+3 -3
View File
@@ -20,7 +20,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", user = false) {
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_ALL event to be processed
await delayUntil(
10000,
() => cache.messages.get(message.id)?.reactions?.length === 1,
() => cache.messages.get(message.id)?.reactions?.length === 1
);
// Be sure that the message has the reactions
@@ -31,7 +31,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", user = false) {
message.channelId,
message.id,
"❤",
user ? { userId: message.authorId } : undefined,
user ? { userId: message.authorId } : undefined
);
} else {
await message.removeReaction("❤", user ? message.authorId : undefined);
@@ -40,7 +40,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", user = false) {
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_REMOVE_ALL event to be processed
await delayUntil(
10000,
() => cache.messages.get(message.id)?.reactions === undefined,
() => cache.messages.get(message.id)?.reactions === undefined
);
// Check if the reactions has been deleted
+2 -2
View File
@@ -25,7 +25,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_ALL event to be processed
await delayUntil(
10000,
() => cache.messages.get(message.id)?.reactions?.length === 1,
() => cache.messages.get(message.id)?.reactions?.length === 1
);
// Be sure that the message has the reactions
@@ -40,7 +40,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
// Delay the execution by 5 seconds to allow MESSAGE_REACTION_REMOVE_ALL event to be processed
await delayUntil(
10000,
() => cache.messages.get(message.id)?.reactions === undefined,
() => cache.messages.get(message.id)?.reactions === undefined
);
// Check if the reactions has been deleted
+2 -2
View File
@@ -23,7 +23,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
const pins = await getPins(tempData.channelId);
assertEquals(
pins.filter((msg: DiscordenoMessage) => msg.id === message.id).length,
1,
1
);
if (type === "raw") {
@@ -37,7 +37,7 @@ async function ifItFailsBlameWolf(type: "getter" | "raw") {
assertEquals(
removedPins.filter((msg: DiscordenoMessage) => msg.id === message.id)
.length,
0,
0
);
}
+12 -13
View File
@@ -14,9 +14,8 @@ 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)) {
@@ -30,19 +29,19 @@ 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)
);
assertEquals(
cache.members.get(botId)?.guilds.get(tempData.guildId)!.roles.includes(
role.id,
),
true,
cache.members
.get(botId)
?.guilds.get(tempData.guildId)!
.roles.includes(role.id),
true
);
}
+9 -6
View File
@@ -5,16 +5,19 @@ import { delayUntil } from "../util/delay_until.ts";
import { createRole } from "../../src/helpers/roles/create_role.ts";
async function ifItFailsBlameWolf(reason?: string) {
const role = await createRole(tempData.guildId, {
name: "hoti",
}, reason);
const role = await createRole(
tempData.guildId,
{
name: "hoti",
},
reason
);
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)) {
+11 -8
View File
@@ -6,16 +6,19 @@ import { createRole } from "../../src/helpers/roles/create_role.ts";
import { deleteRole } from "../../src/helpers/roles/delete_role.ts";
async function ifItFailsBlameWolf(reason?: string) {
const role = await createRole(tempData.guildId, {
name: "hoti",
}, reason);
const role = await createRole(
tempData.guildId,
{
name: "hoti",
},
reason
);
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)) {
@@ -27,12 +30,12 @@ async function ifItFailsBlameWolf(reason?: string) {
// 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),
() => !cache.guilds.get(tempData.guildId)?.roles.has(role.id)
);
if (cache.guilds.get(tempData.guildId)?.roles.has(role.id)) {
throw new Error(
`The role should have been deleted but it is still in cache.`,
`The role should have been deleted but it is still in cache.`
);
}
}
+4 -5
View File
@@ -15,9 +15,8 @@ Deno.test({
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)) {
@@ -33,13 +32,13 @@ Deno.test({
10000,
() =>
cache.guilds.get(tempData.guildId)?.roles.get(role.id)?.name ===
"#rememberAyntee",
"#rememberAyntee"
);
assertEquals(
cache.guilds.get(tempData.guildId)?.roles.get(role.id)?.name ===
"#rememberAyntee",
true,
true
);
},
...defaultTestOptions,
+2 -2
View File
@@ -15,12 +15,12 @@ Deno.test({
await delayUntil(
10000,
() =>
cache.members.get(botId)?.guilds.get(tempData.guildId).roles.length > 0,
cache.members.get(botId)?.guilds.get(tempData.guildId).roles.length > 0
);
assertEquals(
cache.members.get(botId)?.guilds.get(tempData.guildId).roles.length > 0,
true,
true
);
},
...defaultTestOptions,
+19 -21
View File
@@ -15,9 +15,8 @@ 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)) {
@@ -31,38 +30,37 @@ 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,
),
!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,
cache.members
.get(botId)
?.guilds.get(tempData.guildId)!
.roles.includes(role.id),
false
);
}
+1 -1
View File
@@ -2,7 +2,7 @@
export async function delayUntil(
maxMs: number,
isReady: () => boolean | undefined,
timeoutTime = 100,
timeoutTime = 100
): Promise<void> {
const maxTime = Date.now() + maxMs;
+3 -6
View File
@@ -44,14 +44,11 @@ Deno.test({
typeof value === "bigint"
? value.toString()
: Array.isArray(value)
? value.map((v) => typeof v === "bigint" ? v.toString() : v)
? value.map((v) => (typeof v === "bigint" ? v.toString() : v))
: value,
`Running for loop in unit test function for changing bigints to strings.`,
`Running for loop in unit test function for changing bigints to strings.`
);
assertEquals(
converted,
correctlyConverted,
);
assertEquals(converted, correctlyConverted);
},
});
+178 -116
View File
@@ -83,15 +83,19 @@ Deno.test({
name: "[utils] validateSlashCommands(): application command name",
fn() {
assertThrows(() =>
validateSlashCommands([{
// The maximum length of the name of an application command is 32.
name: "a".repeat(33),
}])
validateSlashCommands([
{
// The maximum length of the name of an application command is 32.
name: "a".repeat(33),
},
])
);
validateSlashCommands([{
name: "workingname",
}]);
validateSlashCommands([
{
name: "workingname",
},
]);
},
});
@@ -103,9 +107,11 @@ Deno.test({
validateSlashCommands([{ description: "a".repeat(101) }])
);
validateSlashCommands([{
description: "valid description (should not throw)",
}]);
validateSlashCommands([
{
description: "valid description (should not throw)",
},
]);
},
});
@@ -122,9 +128,11 @@ Deno.test({
assertThrows(() => validateSlashCommands([{ options }]));
validateSlashCommands([{
options: [option],
}]);
validateSlashCommands([
{
options: [option],
},
]);
},
});
@@ -139,24 +147,32 @@ Deno.test({
const choices = Array(26).fill(choice);
assertThrows(() =>
validateSlashCommands([{
options: [{
name: "optionname",
type: DiscordApplicationCommandOptionTypes.String,
description: "The description of the option.",
choices,
}],
}])
validateSlashCommands([
{
options: [
{
name: "optionname",
type: DiscordApplicationCommandOptionTypes.String,
description: "The description of the option.",
choices,
},
],
},
])
);
validateSlashCommands([{
options: [{
name: "optionname",
type: DiscordApplicationCommandOptionTypes.String,
description: "The description of the option.",
choices: [choice],
}],
}]);
validateSlashCommands([
{
options: [
{
name: "optionname",
type: DiscordApplicationCommandOptionTypes.String,
description: "The description of the option.",
choices: [choice],
},
],
},
]);
},
});
@@ -164,23 +180,31 @@ Deno.test({
name: "[utils] validateSlashCommands(): option name",
fn() {
assertThrows(() =>
validateSlashCommands([{
options: [{
// The maximum length of application command option name is 32.
name: "a".repeat(33),
description: "The description of the option.",
type: DiscordApplicationCommandOptionTypes.String,
}],
}])
validateSlashCommands([
{
options: [
{
// The maximum length of application command option name is 32.
name: "a".repeat(33),
description: "The description of the option.",
type: DiscordApplicationCommandOptionTypes.String,
},
],
},
])
);
validateSlashCommands([{
options: [{
name: "optionname",
description: "The description of the option.",
type: DiscordApplicationCommandOptionTypes.String,
}],
}]);
validateSlashCommands([
{
options: [
{
name: "optionname",
description: "The description of the option.",
type: DiscordApplicationCommandOptionTypes.String,
},
],
},
]);
},
});
@@ -188,23 +212,31 @@ Deno.test({
name: "[utils] validateSlashCommands(): option description",
fn() {
assertThrows(() =>
validateSlashCommands([{
options: [{
name: "optionname",
// The maximum length of application command option description is 100.
description: "a".repeat(101),
type: DiscordApplicationCommandOptionTypes.String,
}],
}])
validateSlashCommands([
{
options: [
{
name: "optionname",
// The maximum length of application command option description is 100.
description: "a".repeat(101),
type: DiscordApplicationCommandOptionTypes.String,
},
],
},
])
);
validateSlashCommands([{
options: [{
name: "optionname",
description: "The description of the option.",
type: DiscordApplicationCommandOptionTypes.String,
}],
}]);
validateSlashCommands([
{
options: [
{
name: "optionname",
description: "The description of the option.",
type: DiscordApplicationCommandOptionTypes.String,
},
],
},
]);
},
});
@@ -212,31 +244,43 @@ Deno.test({
name: "[utils] validateSlashCommands(): the option choice name",
fn() {
assertThrows(() =>
validateSlashCommands([{
options: [{
name: "optionname",
choices: [{
// The maximum length of an option choice name is 100.
name: "a".repeat(101),
value: "choicevalue",
}],
description: "The description of the option.",
type: DiscordApplicationCommandOptionTypes.String,
}],
}])
validateSlashCommands([
{
options: [
{
name: "optionname",
choices: [
{
// The maximum length of an option choice name is 100.
name: "a".repeat(101),
value: "choicevalue",
},
],
description: "The description of the option.",
type: DiscordApplicationCommandOptionTypes.String,
},
],
},
])
);
validateSlashCommands([{
options: [{
name: "optionname",
description: "The description of the option.",
type: DiscordApplicationCommandOptionTypes.String,
choices: [{
name: "choicename",
value: "choicevalue",
}],
}],
}]);
validateSlashCommands([
{
options: [
{
name: "optionname",
description: "The description of the option.",
type: DiscordApplicationCommandOptionTypes.String,
choices: [
{
name: "choicename",
value: "choicevalue",
},
],
},
],
},
]);
},
});
@@ -244,44 +288,62 @@ Deno.test({
name: "[utils] validateSlashCommands(): option choice value",
fn() {
assertThrows(() =>
validateSlashCommands([{
options: [{
type: DiscordApplicationCommandOptionTypes.String,
description: "The description of the option.",
name: "optionname",
choices: [{
name: "choicename",
value: 123,
}],
}],
}])
validateSlashCommands([
{
options: [
{
type: DiscordApplicationCommandOptionTypes.String,
description: "The description of the option.",
name: "optionname",
choices: [
{
name: "choicename",
value: 123,
},
],
},
],
},
])
);
assertThrows(() => {
validateSlashCommands([{
options: [{
description: "The description of the option.",
name: "optionname",
type: DiscordApplicationCommandOptionTypes.String,
choices: [{
name: "choicename",
// The maximum length of an option choice value is 100.
value: "a".repeat(101),
}],
}],
}]);
validateSlashCommands([
{
options: [
{
description: "The description of the option.",
name: "optionname",
type: DiscordApplicationCommandOptionTypes.String,
choices: [
{
name: "choicename",
// The maximum length of an option choice value is 100.
value: "a".repeat(101),
},
],
},
],
},
]);
});
validateSlashCommands([{
options: [{
type: DiscordApplicationCommandOptionTypes.String,
description: "The description of the option.",
name: "optionname",
choices: [{
name: "choicename",
value: "choicevalue",
}],
}],
}]);
validateSlashCommands([
{
options: [
{
type: DiscordApplicationCommandOptionTypes.String,
description: "The description of the option.",
name: "optionname",
choices: [
{
name: "choicename",
value: "choicevalue",
},
],
},
],
},
]);
},
});
+1 -1
View File
@@ -38,7 +38,7 @@ Deno.test({
await startBot({
token,
eventHandlers: {
ready: () => didReady = true,
ready: () => (didReady = true),
},
intents: [
"GuildMessages",