mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 20:42:27 +00:00
Add additional shard count checks
This commit is contained in:
parent
5ea62e63ab
commit
65b93532ce
1 changed files with 6 additions and 0 deletions
|
|
@ -79,8 +79,14 @@ class ShardingManager extends EventEmitter {
|
|||
if (amount !== Math.floor(amount)) throw new RangeError('Amount of shards must be an integer.');
|
||||
|
||||
return new Promise(resolve => {
|
||||
if (this.shards.size >= amount) throw new Error(`Already spawned ${this.shards.size} shards.`);
|
||||
this.totalShards = amount;
|
||||
|
||||
this.createShard();
|
||||
if (this.shards.size >= this.totalShards) {
|
||||
resolve(this.shards);
|
||||
return;
|
||||
}
|
||||
|
||||
if (delay <= 0) {
|
||||
while (this.shards.size < this.totalShards) this.createShard();
|
||||
|
|
|
|||
Loading…
Reference in a new issue