mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
Fix ready never firing for truly unavailable guilds
This commit is contained in:
@@ -44,6 +44,12 @@ class WebSocketManager {
|
||||
* @type {?string}
|
||||
*/
|
||||
this.gateway = null;
|
||||
|
||||
/**
|
||||
* Whether READY was emitted normally (all packets received) or not
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.normalReady = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,6 +57,7 @@ class WebSocketManager {
|
||||
* @param {string} gateway the gateway to connect to
|
||||
*/
|
||||
connect(gateway) {
|
||||
this.normalReady = false;
|
||||
this.status = Constants.Status.CONNECTING;
|
||||
/**
|
||||
* The WebSocket connection to the gateway
|
||||
@@ -200,7 +207,7 @@ class WebSocketManager {
|
||||
this.tryReconnect();
|
||||
}
|
||||
|
||||
_emitReady() {
|
||||
_emitReady(normal = true) {
|
||||
/**
|
||||
* Emitted when the Client becomes ready to start working
|
||||
*
|
||||
@@ -209,6 +216,7 @@ class WebSocketManager {
|
||||
this.status = Constants.Status.READY;
|
||||
this.client.emit(Constants.Events.READY);
|
||||
this.packetManager.handleQueue();
|
||||
this.normalReady = normal;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,12 @@ class ReadyHandler extends AbstractHandler {
|
||||
|
||||
client.once('ready', client.syncGuilds.bind(client));
|
||||
|
||||
client.setTimeout(() => {
|
||||
if (!client.ws.normalReady) {
|
||||
client.ws._emitReady(false);
|
||||
}
|
||||
}, 1200 * data.guilds.length);
|
||||
|
||||
this.packetManager.ws.sessionID = data.session_id;
|
||||
|
||||
this.packetManager.ws.checkIfReady();
|
||||
|
||||
Reference in New Issue
Block a user