mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
Clean up totalShards default
This commit is contained in:
@@ -17,7 +17,7 @@ class ShardingManager extends EventEmitter {
|
|||||||
* @param {number} [totalShards=1] Number of shards to default to spawning
|
* @param {number} [totalShards=1] Number of shards to default to spawning
|
||||||
* @param {boolean} [respawn=true] Respawn a shard when it dies
|
* @param {boolean} [respawn=true] Respawn a shard when it dies
|
||||||
*/
|
*/
|
||||||
constructor(file, totalShards, respawn = true) {
|
constructor(file, totalShards = 1, respawn = true) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,12 +34,12 @@ class ShardingManager extends EventEmitter {
|
|||||||
* Amount of shards that this manager is going to spawn
|
* Amount of shards that this manager is going to spawn
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.totalShards = typeof totalShards !== 'undefined' ? totalShards : 1;
|
this.totalShards = totalShards;
|
||||||
if (typeof this.totalShards !== 'number' || isNaN(this.totalShards)) {
|
if (typeof totalShards !== 'number' || isNaN(totalShards)) {
|
||||||
throw new TypeError('Amount of shards must be a number.');
|
throw new TypeError('Amount of shards must be a number.');
|
||||||
}
|
}
|
||||||
if (this.totalShards < 1) throw new RangeError('Amount of shards must be at least 1.');
|
if (totalShards < 1) throw new RangeError('Amount of shards must be at least 1.');
|
||||||
if (this.totalShards !== Math.floor(this.totalShards)) throw new RangeError('Amount of shards must be an integer.');
|
if (totalShards !== Math.floor(totalShards)) throw new RangeError('Amount of shards must be an integer.');
|
||||||
|
|
||||||
this.respawn = respawn;
|
this.respawn = respawn;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user