From 71cc258fdd3536ab95f9b36833e3758536c9fa4a Mon Sep 17 00:00:00 2001 From: ckohen Date: Mon, 2 Aug 2021 17:26:42 -0700 Subject: [PATCH] fix(WebSocketShard): mark shard ready if no guilds intent --- src/client/websocket/WebSocketShard.js | 12 +++++++++--- typings/index.d.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index ab5b9216411d..02083a3ac6d6 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; } + let time = 15000; + if (!new Intents(this.manager.client.options.intents).has(Intents.FLAGS.GUILDS)) { + time = 0; + } // 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.debug( + `Shard ${time === 0 ? 'will' : 'did'} not receive any more guild packets` + + `${time === 0 ? '' : ' in 15 seconds'}.\n Unavailable guild count: ${this.expectedGuilds.size}`, + ); this.readyTimeout = null; this.status = Status.READY; this.emit(ShardEvents.ALL_READY, this.expectedGuilds); - }, 15000).unref(); + }, time).unref(); } /** diff --git a/typings/index.d.ts b/typings/index.d.ts index 520f5b6bc8b2..8549af6eced8 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2047,7 +2047,7 @@ export class WebSocketShard extends EventEmitter { private onError(error: ErrorEvent | unknown): void; private onClose(event: CloseEvent): void; private onPacket(packet: unknown): void; - private checkReady(): void; + private checkReady(epxectGuilds?: boolean): void; private setHelloTimeout(time?: number): void; private setHeartbeatTimer(time: number): void; private sendHeartbeat(): void;