mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
* p1 of bigints change * shtuff fixes and bits * Commit from GitHub Actions (Lint) * finish bigint structs * typings fixes * Commit from GitHub Actions (Lint) * more fixes * Commit from GitHub Actions (Lint) * more fixes * Commit from GitHub Actions (Lint) * blame wolf * Commit from GitHub Actions (Lint) * foxed * Commit from GitHub Actions (Lint) * fix unit tests * Commit from GitHub Actions (Lint) * change: guildUpdate guild ID can't change * delete server has been renamed to delete guild * fixes Co-authored-by: Skillz4Killz <Skillz4Killz@users.noreply.github.com> Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com>
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import { botId, startBot } from "../../src/bot.ts";
|
|
import { cache } from "../../src/cache.ts";
|
|
import { deleteGuild } from "../../src/helpers/guilds/delete_guild.ts";
|
|
import { delay } from "../../src/util/utils.ts";
|
|
import { ws } from "../../src/ws/ws.ts";
|
|
import { assertExists } from "../deps.ts";
|
|
|
|
// Set necessary settings
|
|
// Disables the logger which logs everything
|
|
ws.log = function (_x: string, _d: unknown) {
|
|
// if (["RAW", "GUILD_CREATE", "HEARTBEATING_DETAILS"].includes(_x))
|
|
// return console.log(_x);
|
|
// console.log(_x, _d);
|
|
};
|
|
|
|
// Default options for tests
|
|
export const defaultTestOptions: Partial<Deno.TestDefinition> = {
|
|
sanitizeOps: false,
|
|
sanitizeResources: false,
|
|
};
|
|
|
|
// Temporary data
|
|
export const tempData = {
|
|
guildId: 0n,
|
|
roleId: 0n,
|
|
channelId: 0n,
|
|
messageId: 0n,
|
|
};
|
|
|
|
Deno.test({
|
|
name: "[ws] connect to gateway",
|
|
async fn() {
|
|
const token = Deno.env.get("DISCORD_TOKEN");
|
|
if (!token) throw new Error("Token is not provided");
|
|
|
|
await startBot({
|
|
token,
|
|
intents: [
|
|
"GUILD_MESSAGES",
|
|
"GUILDS",
|
|
"GUILD_EMOJIS",
|
|
"GUILD_MESSAGE_REACTIONS",
|
|
"GUILD_EMOJIS",
|
|
],
|
|
});
|
|
|
|
// Delay the execution by 5 seconds
|
|
await delay(3000);
|
|
|
|
// DELETE GUILDS IF LESS THAN 10 SERVERS AS SAFETY MEASURE
|
|
if (cache.guilds.size <= 10) {
|
|
for (const guild of cache.guilds.values()) await deleteGuild(guild.id);
|
|
}
|
|
|
|
// Assertions
|
|
assertExists(botId);
|
|
},
|
|
...defaultTestOptions,
|
|
});
|