Fix some destroy stuff (#828)

This commit is contained in:
Amish Shah
2016-10-26 19:42:21 +01:00
parent a2f125e416
commit 5e2ee2398e
2 changed files with 9 additions and 11 deletions

View File

@@ -235,16 +235,14 @@ class Client extends EventEmitter {
*/
destroy() {
return new Promise((resolve, reject) => {
this.manager.destroy().then(() => {
for (const t of this._timeouts) clearTimeout(t);
for (const i of this._intervals) clearInterval(i);
this._timeouts = [];
this._intervals = [];
this.token = null;
this.email = null;
this.password = null;
resolve();
}).catch(reject);
for (const t of this._timeouts) clearTimeout(t);
for (const i of this._intervals) clearInterval(i);
this._timeouts = [];
this._intervals = [];
this.token = null;
this.email = null;
this.password = null;
this.manager.destroy().then(resolve).catch(reject);
});
}