From 9afec41467572a5a0ea391207dcb5824d608ea36 Mon Sep 17 00:00:00 2001 From: Lio Young Date: Wed, 28 Apr 2021 03:31:12 +0200 Subject: [PATCH] different sharding method --- index.ts | 11 +---------- package.json | 4 ++-- shard.ts | 12 ++++++++++++ 3 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 shard.ts diff --git a/index.ts b/index.ts index 868b5fe..f23bd11 100644 --- a/index.ts +++ b/index.ts @@ -1,13 +1,4 @@ //@ts-ignore import config from "./config"; import client from "./src/handler/client/Client" -import { Util } from "discord.js"; -import Logger from "./src/utils/logger"; -Util.fetchRecommendedShards(config.token).then((count) => { - // console.log(`Starting ${config.variables.name}`) - Logger.info({ - message: `Starting ${config.variables.name} with ${count} Shards`, - type: "event:start" - }) - new client(config, count) -}) +let Bot = new client(config) diff --git a/package.json b/package.json index 0b6a4e8..cb97766 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,10 @@ "name": "thaldrin", "version": "4.0.0-dev", "description": "", - "main": "build/index.js", + "main": "build/shard.js", "scripts": { "build": "tsc", - "start": "node build/index.js", + "start": "node build/shard.js", "dev": "npm run build && npm run start", "init": "npm run subs:init && npm run sub:update", "subs:init": "git submodules init && git submodule update", diff --git a/shard.ts b/shard.ts new file mode 100644 index 0000000..69d0fef --- /dev/null +++ b/shard.ts @@ -0,0 +1,12 @@ +import { ShardingManager } from "discord.js"; +import config from "./config"; +let Sharder = new ShardingManager('./build/index.js', { + token: config.token, + totalShards: "auto" +}) + +Sharder.on("shardCreate", async (shard) => { + console.log(`Launched Shard #${shard.id}`) +}) + +Sharder.spawn() \ No newline at end of file