mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 20:42:27 +00:00
Fix ready never firing for truly unavailable guilds
This commit is contained in:
parent
68acf37fd4
commit
09dee3d46a
2 changed files with 15 additions and 1 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue