Skip to content

Commit

Permalink
fix(WebSocketShard): mark shard ready if no guilds intent
Browse files Browse the repository at this point in the history
  • Loading branch information
ckohen committed Aug 3, 2021
1 parent 35fa3b3 commit 71cc258
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/client/websocket/WebSocketShard.js
Expand Up @@ -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();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Expand Up @@ -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;
Expand Down

0 comments on commit 71cc258

Please sign in to comment.