mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev
This commit is contained in:
@@ -234,17 +234,14 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
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);
|
||||
return this.manager.destroy().then(() => {
|
||||
for (const t of this._timeouts) clearTimeout(t);
|
||||
for (const i of this._intervals) clearInterval(i);
|
||||
this._timeouts.clear();
|
||||
this._intervals.clear();
|
||||
this.token = null;
|
||||
this.email = null;
|
||||
this.password = null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -58,14 +58,11 @@ class ClientManager {
|
||||
}
|
||||
|
||||
destroy() {
|
||||
return new Promise((resolve) => {
|
||||
if (!this.client.user.bot) {
|
||||
this.client.rest.methods.logout().then(resolve);
|
||||
} else {
|
||||
this.client.ws.destroy();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
let p = Promise.resolve();
|
||||
if (!this.client.user.bot) {
|
||||
p = this.client.rest.methods.logout();
|
||||
}
|
||||
return p.then(() => this.client.ws.destroy());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class RESTMethods {
|
||||
}
|
||||
|
||||
logout() {
|
||||
return this.rest.makeRequest('post', Constants.Endpoints.logout, true);
|
||||
return this.rest.makeRequest('post', Constants.Endpoints.logout, true, {});
|
||||
}
|
||||
|
||||
getGateway() {
|
||||
|
||||
12
test/destroy.js
Normal file
12
test/destroy.js
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const Discord = require('../');
|
||||
|
||||
const client = new Discord.Client({ fetch_all_members: false, api_request_method: 'sequential' });
|
||||
|
||||
const { email, password, token } = require('./auth.json');
|
||||
|
||||
let p = client.login(token);
|
||||
p = p.then(() => client.destroy());
|
||||
p = p.then(() => client.login(token));
|
||||
p = p.then(() => client.destroy());
|
||||
Reference in New Issue
Block a user