mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
Add delay param to ShardingManager.spawn
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -64,8 +64,9 @@ class ShardingManager extends EventEmitter {
|
|||||||
/**
|
/**
|
||||||
* Spawns multiple shards.
|
* Spawns multiple shards.
|
||||||
* @param {number} [amount=this.totalShards] Number of shards to spawn
|
* @param {number} [amount=this.totalShards] Number of shards to spawn
|
||||||
|
* @param {number} [delay=5500] How long to wait in between spawning each shard (in milliseconds)
|
||||||
*/
|
*/
|
||||||
spawn(amount) {
|
spawn(amount, delay = 5500) {
|
||||||
if (typeof amount !== 'undefined') {
|
if (typeof amount !== 'undefined') {
|
||||||
if (typeof amount !== 'number' || isNaN(amount)) throw new TypeError('Amount of shards must be a number.');
|
if (typeof amount !== 'number' || isNaN(amount)) throw new TypeError('Amount of shards must be a number.');
|
||||||
if (amount < 1) throw new RangeError('Amount of shards must be at least 1.');
|
if (amount < 1) throw new RangeError('Amount of shards must be at least 1.');
|
||||||
@@ -76,7 +77,7 @@ class ShardingManager extends EventEmitter {
|
|||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
if (this.shards.size === this.totalShards) clearInterval(interval);
|
if (this.shards.size === this.totalShards) clearInterval(interval);
|
||||||
else this.createShard();
|
else this.createShard();
|
||||||
}, 5500);
|
}, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user