Fix ready never firing for truly unavailable guilds

This commit is contained in:
Amish Shah
2016-09-03 21:10:05 +01:00
parent 68acf37fd4
commit 09dee3d46a
2 changed files with 15 additions and 1 deletions

View File

@@ -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;
}
/**

View File

@@ -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();