From 12f57e9195b1d0696751575066ff1eb798347e9a Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 4 Sep 2024 09:44:24 +0200 Subject: [PATCH 1/4] add basic sharding --- src/bot.ts | 6 ++++++ src/index.ts | 16 ++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 src/bot.ts diff --git a/src/bot.ts b/src/bot.ts new file mode 100644 index 0000000..fbfd0c0 --- /dev/null +++ b/src/bot.ts @@ -0,0 +1,6 @@ +/** Load the app. */ +const start_app = () => { + import("./load").then((l) => l.run().catch((error) => console.error(error))); +}; + +start_app(); diff --git a/src/index.ts b/src/index.ts index fc96eb6..dd53b69 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,17 +1,21 @@ -/** Load the app. */ -const start_app = () => { - import("./load").then((l) => l.run().catch((error) => console.error(error))); +import { ShardingManager } from "discord.js"; + +const start_manager = () => { + const manager = new ShardingManager("./dist/bot.js", { token: process.env.TOKEN_DISCORD }); + + manager.on("shardCreate", (shard) => console.log(`Launched shard ${shard.id}`)); + + manager.spawn(); }; -// Load .env if not in prod if (process.env.NODE_ENV !== "production") { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import("dotenv").then((c) => { c.config({ path: "./config/.env" }); - start_app(); + start_manager(); }); } else { - start_app(); + start_manager(); } -- 2.45.2 From e43234f7905efee3ea1bdb4f056e54717e012180 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 4 Sep 2024 13:04:11 +0200 Subject: [PATCH 2/4] comments --- src/bot.ts | 2 +- src/index.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bot.ts b/src/bot.ts index fbfd0c0..b62e76c 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -1,4 +1,4 @@ -/** Load the app. */ +/** Load the app */ const start_app = () => { import("./load").then((l) => l.run().catch((error) => console.error(error))); }; diff --git a/src/index.ts b/src/index.ts index dd53b69..7c5aeaf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,7 @@ const start_manager = () => { manager.spawn(); }; +// Load .env if not in prod if (process.env.NODE_ENV !== "production") { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore -- 2.45.2 From 0747c3ebe4c9da956fcf4a0a074044085eabac19 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 4 Sep 2024 13:06:54 +0200 Subject: [PATCH 3/4] disable ok-lines --- src/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7c5aeaf..2f6e5a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,8 +10,6 @@ const start_manager = () => { // Load .env if not in prod if (process.env.NODE_ENV !== "production") { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore import("dotenv").then((c) => { c.config({ path: "./config/.env" }); -- 2.45.2 From 4ef2e1f1b42f71b936e252a7c7ba961a173c63ff Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 4 Sep 2024 13:13:30 +0200 Subject: [PATCH 4/4] disable internal sharding --- src/utils/client.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/client.ts b/src/utils/client.ts index b096546..d4aeeb3 100644 --- a/src/utils/client.ts +++ b/src/utils/client.ts @@ -9,7 +9,6 @@ import { YoutubeiExtractor } from "discord-player-youtubei"; /** Creation of the client and definition of its properties */ export default async () => { const client: Client = new Client({ - shards: "auto", intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, -- 2.45.2