mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
Cleanup Part 2: Electric Boogaloo (Reloaded) (#594)
* Cleanup Part 2: Electric Boogaloo (Reloaded) * Moar cleanup * Tweak NOT_A_PERMISSION error
This commit is contained in:
committed by
Amish Shah
parent
5a9c42061f
commit
0b908f5bce
@@ -15,10 +15,8 @@ const Collection = require('../util/Collection');
|
||||
* @extends {EventEmitter}
|
||||
*/
|
||||
class Client extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Creates an instance of Client.
|
||||
* @param {ClientOptions} [options] options to pass to the client
|
||||
* @param {ClientOptions} [options] Options for the client
|
||||
*/
|
||||
constructor(options) {
|
||||
super();
|
||||
@@ -129,17 +127,13 @@ class Client extends EventEmitter {
|
||||
* client.login(email, password);
|
||||
*/
|
||||
login(emailOrToken, password) {
|
||||
if (password) {
|
||||
// login with email and password
|
||||
return this.rest.methods.loginEmailPassword(emailOrToken, password);
|
||||
}
|
||||
// login with token
|
||||
if (password) return this.rest.methods.loginEmailPassword(emailOrToken, password);
|
||||
return this.rest.methods.loginToken(emailOrToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the client and logs out. Resolves with null if successful.
|
||||
* @returns {Promise<null, Error>}
|
||||
* Destroys the client and logs out.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
destroy() {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -152,8 +146,7 @@ class Client extends EventEmitter {
|
||||
this._timeouts = [];
|
||||
this._intervals = [];
|
||||
resolve();
|
||||
})
|
||||
.catch(reject);
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -176,7 +169,7 @@ class Client extends EventEmitter {
|
||||
/**
|
||||
* This shouldn't really be necessary to most developers as it is automatically invoked every 30 seconds, however
|
||||
* if you wish to force a sync of Guild data, you can use this. Only applicable to user accounts.
|
||||
* @param {array<Guild>} [guilds=this.guilds.array()] An array of guilds to sync.
|
||||
* @param {Guild[]} [guilds=this.guilds.array()] An array of guilds to sync
|
||||
*/
|
||||
syncGuilds(guilds = this.guilds.array()) {
|
||||
if (!this.user.bot) {
|
||||
@@ -215,7 +208,6 @@ class Client extends EventEmitter {
|
||||
get uptime() {
|
||||
return this.readyTime ? Date.now() - this.readyTime : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
|
||||
Reference in New Issue
Block a user