Skip to content

Commit

Permalink
fix totalShards: auto error
Browse files Browse the repository at this point in the history
  • Loading branch information
meister03 committed Apr 28, 2021
1 parent 0d9a078 commit 68d63bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions ClusterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ClusterManager extends EventEmitter {
totalShards: 'auto',
shardArgs: [],
execArgv: [],
mode: 'worker',
mode: 'process',
shardList: 'auto',
token: process.env.DISCORD_TOKEN,
},
Expand Down Expand Up @@ -80,7 +80,7 @@ class ClusterManager extends EventEmitter {
*/
this.mode = options.mode;
if (this.mode !== 'worker' && this.mode !== "process") {
throw new RangeError('CLIENT_INVALID_OPTION', 'Cluster mode', '"worker"');
throw new RangeError('CLIENT_INVALID_OPTION', 'Cluster mode', '"worker/process"');
}

/**
Expand Down Expand Up @@ -148,6 +148,7 @@ class ClusterManager extends EventEmitter {
async spawn(amount = this.totalShards, delay = 5500, spawnTimeout) {
if (amount === 'auto') {
amount = await Discord.fetchRecommendedShards(this.token, 1000);
this.totalShards = amount;
} else {
if (typeof amount !== 'number' || isNaN(amount)) {
throw new TypeError('CLIENT_INVALID_OPTION', 'Amount of internal shards', 'a number.');
Expand All @@ -174,7 +175,7 @@ class ClusterManager extends EventEmitter {
if(this.shardList === "auto") this.shardList = [...Array(amount).keys()];
this.shardclusterlist = this.shardList.chunk(Math.ceil(this.shardList.length/this.totalClusters));
if(this.shardclusterlist.length !== this.totalClusters){
this.totalClusters = this.shardclusterlist.length;
this.totalClusters = this.shardclusterlist.length ;
}
if (this.shardList.some(shardID => shardID >= amount)) {
throw new RangeError(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord-hybrid-sharding",
"version": "1.0.7",
"version": "1.0.8",
"description": "The first package which combines Sharding Manager & Internal Sharding to save a lot of ressources",
"main": "index.js",
"types": "./typings.d.ts",
Expand Down

0 comments on commit 68d63bc

Please sign in to comment.