Add client.destroy();

This commit is contained in:
Amish Shah
2016-08-30 13:05:50 +01:00
parent 56352220af
commit d249aa10cc
18 changed files with 74 additions and 42 deletions

View File

@@ -35,7 +35,7 @@ class ClientManager {
})
.catch(reject);
setTimeout(() => reject(Constants.Errors.TOOK_TOO_LONG), 1000 * 300);
this.client.setTimeout(() => reject(Constants.Errors.TOOK_TOO_LONG), 1000 * 300);
}
/**
@@ -44,13 +44,24 @@ class ClientManager {
* @returns {null}
*/
setupKeepAlive(time) {
this.heartbeatInterval = setInterval(() => {
this.heartbeatInterval = this.client.setInterval(() => {
this.client.ws.send({
op: Constants.OPCodes.HEARTBEAT,
d: Date.now(),
});
}, time);
}
destroy() {
return new Promise((resolve) => {
if (!this.client.user.bot) {
this.client.rest.methods.logout().then(resolve);
} else {
this.client.ws.destroy();
resolve();
}
});
}
}
module.exports = ClientManager;