UNPKG

status-sharding

Version:

Welcome to Status Sharding! This package is designed to provide an efficient and flexible solution for sharding Discord bots, allowing you to scale your bot across multiple processes or workers.

28 lines (27 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ShardingClient = void 0; const discord_js_1 = require("discord.js"); const utils_1 = require("../other/utils"); const clusterClient_1 = require("./clusterClient"); /** Modified DiscordClient with bunch of new methods. */ class ShardingClient extends discord_js_1.Client { /** Cluster associated with this client. */ cluster; /** Creates an instance of ShardingClient. */ constructor(options) { super({ ...options, shards: (0, utils_1.getInfo)().ShardList, shardCount: (0, utils_1.getInfo)().TotalShards, }); this.cluster = new clusterClient_1.ClusterClient(this); this.shardsReady(); } async shardsReady() { const { major, minor, patch } = await (0, utils_1.getDiscordVersion)('discord.js'); const useClientReady = major > 14 || (major === 14 && (minor > 22 || (minor === 22 && patch >= 0))); this.on(useClientReady ? 'clientReady' : 'ready', () => this.cluster.triggerReady()); } } exports.ShardingClient = ShardingClient;