Skip to content

Commit

Permalink
fix(WebSocketShard): mark shard ready if no guilds intent (#6284)
Browse files Browse the repository at this point in the history
Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
  • Loading branch information
ckohen and NotSugden committed Aug 3, 2021
1 parent 61db5f7 commit 09471be
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/client/websocket/WebSocketShard.js
Expand Up @@ -474,17 +474,23 @@ class WebSocketShard extends EventEmitter {
this.emit(ShardEvents.ALL_READY);
return;
}
const hasGuildsIntent = new Intents(this.manager.client.options.intents).has(Intents.FLAGS.GUILDS);
// Step 2. Create a 15s timeout that will mark the shard as ready if there are still unavailable guilds
this.readyTimeout = setTimeout(() => {
this.debug(`Shard did not receive any more guild packets in 15 seconds.
Unavailable guild count: ${this.expectedGuilds.size}`);
this.readyTimeout = setTimeout(
() => {
this.debug(
`Shard ${hasGuildsIntent ? 'did' : 'will'} not receive any more guild packets` +
`${hasGuildsIntent ? ' in 15 seconds' : ''}.\n Unavailable guild count: ${this.expectedGuilds.size}`,
);

this.readyTimeout = null;
this.readyTimeout = null;

this.status = Status.READY;
this.status = Status.READY;

this.emit(ShardEvents.ALL_READY, this.expectedGuilds);
}, 15000).unref();
this.emit(ShardEvents.ALL_READY, this.expectedGuilds);
},
hasGuildsIntent ? 15000 : 0,
).unref();
}

/**
Expand Down

0 comments on commit 09471be

Please sign in to comment.