mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 14:38:49 +00:00
feat!: Sharding implemented across the bot
This commit is contained in:
1 parent
b160cbf564
commit
9c15c636d9
29 files changed
+270
-142
No files matched your search
+3
-5
@@ -1,18 +1,16 @@
|
||||
require('dotenv').config();
|
||||
const { shardingOptions } = require('./config');
|
||||
const logger = require('./services/logger');
|
||||
const { ShardingManager, ShardEvents } = require('discord.js');
|
||||
|
||||
const manager = new ShardingManager('./src/bot.js', {
|
||||
token: process.env.DISCORD_BOT_TOKEN,
|
||||
totalShards: 2,
|
||||
shardList: 'auto',
|
||||
mode: 'process',
|
||||
respawn: true
|
||||
...shardingOptions
|
||||
});
|
||||
|
||||
const readyShards = new Set();
|
||||
manager.on('shardCreate', (shard) => {
|
||||
logger.debug(`Launched shard ${shard.id}`);
|
||||
logger.debug(`[Shard ${shard.id}] Launched shard with id ${shard.id}.`);
|
||||
|
||||
// When all shards are ready, emit event 'allShardsReady' to all shards
|
||||
shard.on(ShardEvents.Ready, () => {
|
||||
|
||||
Reference in new issue
Block a user