mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 21:12:06 +00:00
simplify client destruction
This commit is contained in:
parent
5e2ee2398e
commit
00fe45f6b3
2 changed files with 9 additions and 11 deletions
|
|
@ -234,16 +234,14 @@ class Client extends EventEmitter {
|
|||
* @returns {Promise}
|
||||
*/
|
||||
destroy() {
|
||||
return new Promise((resolve, 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);
|
||||
});
|
||||
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;
|
||||
return this.manager.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ class ClientManager {
|
|||
|
||||
destroy() {
|
||||
return new Promise((resolve) => {
|
||||
this.client.ws.destroy();
|
||||
if (!this.client.user.bot) {
|
||||
this.client.rest.methods.logout().then(resolve);
|
||||
} else {
|
||||
this.client.ws.destroy();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue