diff --git a/src/bot.ts b/src/bot.ts new file mode 100644 index 0000000..b62e76c --- /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..2f6e5a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,17 +1,20 @@ -/** 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(); } 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,