fix(WebSocketShard): mark shard ready if no guilds intent (#6284)

Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
This commit is contained in:
ckohen
2021-08-03 15:13:18 -07:00
committed by GitHub
parent 61db5f7618
commit 09471be30e

View File

@@ -474,17 +474,23 @@ class WebSocketShard extends EventEmitter {
this.emit(ShardEvents.ALL_READY); this.emit(ShardEvents.ALL_READY);
return; 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 // Step 2. Create a 15s timeout that will mark the shard as ready if there are still unavailable guilds
this.readyTimeout = setTimeout(() => { 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 ${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); this.emit(ShardEvents.ALL_READY, this.expectedGuilds);
}, 15000).unref(); },
hasGuildsIntent ? 15000 : 0,
).unref();
} }
/** /**