make login sane (#735)

This commit is contained in:
Gus Caplan
2016-09-24 11:55:31 -05:00
committed by Amish Shah
parent 116e6bb4c8
commit bd1449bc5a
3 changed files with 11 additions and 2 deletions

View File

@@ -32,6 +32,10 @@ class ClientManager {
this.client.rest.methods.getGateway().then(gateway => {
this.client.emit(Constants.Events.DEBUG, `Using gateway ${gateway}`);
this.client.ws.connect(gateway);
this.client.ws.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));
});
this.client.once(Constants.Events.READY, () => {
resolve(token);
this.client.clearTimeout(timeout);