From 09471be30eea2540999c3d5a2b001a985a0d27cc Mon Sep 17 00:00:00 2001 From: ckohen Date: Tue, 3 Aug 2021 15:13:18 -0700 Subject: [PATCH] fix(WebSocketShard): mark shard ready if no guilds intent (#6284) Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com> --- src/client/websocket/WebSocketShard.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index ab5b92164..25f66bbfc 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -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(); } /**