invalid token errors not rejected properly (#1478)

* ready event will now throw errors properly

* ws login rejection fix
This commit is contained in:
Drahcirius
2017-05-10 11:14:39 -04:00
committed by Schuyler Cebulskie
parent 83f2c62c3f
commit d11a658f40

View File

@@ -43,7 +43,7 @@ class ClientManager {
const gateway = `${res.url}/?v=${protocolVersion}&encoding=${WebSocketConnection.ENCODING}`;
this.client.emit(Constants.Events.DEBUG, `Using gateway ${gateway}`);
this.client.ws.connect(gateway);
this.client.ws.once('close', event => {
this.client.ws.connection.once('close', event => {
if (event.code === 4004) reject(new Error(Constants.Errors.BAD_LOGIN));
if (event.code === 4010) reject(new Error(Constants.Errors.INVALID_SHARD));
if (event.code === 4011) reject(new Error(Constants.Errors.SHARDING_REQUIRED));