add disconnect event, document warn and debug events (#702)

* add documentation for events, and add a disconnect event, because i know people use that

* generate docs, and fix a hastily copied docstring

* fix permissions freak out
This commit is contained in:
Gus Caplan
2016-09-13 23:12:10 -05:00
committed by Schuyler Cebulskie
parent 25531170ec
commit 7cb2e8eef7
6 changed files with 26 additions and 11 deletions

View File

@@ -25,10 +25,14 @@ class ClientManager {
* @param {function} reject Function to run when connection fails
*/
connectToWebSocket(token, resolve, reject) {
this.client.emit('debug', `Authenticated using token ${token}`);
/**
* Emitted when there is debug information
* @event Client#debug
*/
this.client.emit(Constants.Events.DEBUG, `Authenticated using token ${token}`);
this.client.token = token;
this.client.rest.methods.getGateway().then(gateway => {
this.client.emit('debug', `Using gateway ${gateway}`);
this.client.emit(Constants.Events.DEBUG, `Using gateway ${gateway}`);
this.client.ws.connect(gateway);
this.client.once(Constants.Events.READY, () => resolve(token));
}).catch(reject);