mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
simplify client destruction
This commit is contained in:
@@ -234,16 +234,14 @@ class Client extends EventEmitter {
|
|||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
destroy() {
|
destroy() {
|
||||||
return new Promise((resolve, reject) => {
|
for (const t of this._timeouts) clearTimeout(t);
|
||||||
for (const t of this._timeouts) clearTimeout(t);
|
for (const i of this._intervals) clearInterval(i);
|
||||||
for (const i of this._intervals) clearInterval(i);
|
this._timeouts = [];
|
||||||
this._timeouts = [];
|
this._intervals = [];
|
||||||
this._intervals = [];
|
this.token = null;
|
||||||
this.token = null;
|
this.email = null;
|
||||||
this.email = null;
|
this.password = null;
|
||||||
this.password = null;
|
return this.manager.destroy();
|
||||||
this.manager.destroy().then(resolve).catch(reject);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ class ClientManager {
|
|||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
this.client.ws.destroy();
|
||||||
if (!this.client.user.bot) {
|
if (!this.client.user.bot) {
|
||||||
this.client.rest.methods.logout().then(resolve);
|
this.client.rest.methods.logout().then(resolve);
|
||||||
} else {
|
} else {
|
||||||
this.client.ws.destroy();
|
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user