Add debug stuff

This commit is contained in:
Amish Shah
2016-09-04 12:31:10 +01:00
parent f23c07a08e
commit 7475f734ac
5 changed files with 8 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@@ -25,8 +25,10 @@ class ClientManager {
* @param {function} reject Function to run when connection fails
*/
connectToWebSocket(token, resolve, reject) {
this.client.emit('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.ws.connect(gateway);
this.client.once(Constants.Events.READY, () => resolve(token));
}).catch(reject);

View File

@@ -14,6 +14,7 @@ class RESTMethods {
loginEmailPassword(email, password) {
return new Promise((resolve, reject) => {
this.rest.client.emit('debug', 'client launched using email and password - should use token instead');
this.rest.client.email = email;
this.rest.client.password = password;
this.rest.makeRequest('post', Constants.Endpoints.login, false, { email, password })

View File

@@ -56,6 +56,7 @@ class WebSocketManager {
* @param {string} gateway The gateway to connect to
*/
connect(gateway) {
this.client.emit('debug', `connecting to gateway ${gateway}`);
this.normalReady = false;
this.status = Constants.Status.CONNECTING;
this.ws = new WebSocket(gateway);
@@ -108,6 +109,7 @@ class WebSocketManager {
* Run whenever the gateway connections opens up
*/
eventOpen() {
this.client.emit('debug', 'connection to gateway opened');
if (this.reconnecting) this._sendResume();
else this._sendNewIdentify();
}

View File

@@ -14,6 +14,8 @@ client.on('ready', () => {
console.log('ready!');
});
client.on('debug', console.log);
client.on('message', message => {
if (true) {
if (message.content === 'makechann') {