different sharding method

This commit is contained in:
Lio Young 2021-04-28 03:31:12 +02:00
parent e441cc43fd
commit 9afec41467
No known key found for this signature in database
GPG Key ID: 789795A11879E169
3 changed files with 15 additions and 12 deletions

View File

@ -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)

View File

@ -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",

12
shard.ts Normal file
View File

@ -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()