mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
update per issue 69 on the h&c github (#963)
* update per issue 69 on the h&c github * clean up things that don't exist anymore
This commit is contained in:
@@ -124,18 +124,6 @@ class Client extends EventEmitter {
|
||||
this.token = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The email, if there is one, for the logged in Client
|
||||
* @type {?string}
|
||||
*/
|
||||
this.email = null;
|
||||
|
||||
/**
|
||||
* The password, if there is one, for the logged in Client
|
||||
* @type {?string}
|
||||
*/
|
||||
this.password = null;
|
||||
|
||||
/**
|
||||
* The ClientUser representing the logged in Client
|
||||
* @type {?ClientUser}
|
||||
@@ -236,9 +224,7 @@ class Client extends EventEmitter {
|
||||
* much better to use a bot account rather than a user account.
|
||||
* Bot accounts have higher rate limits and have access to some features user accounts don't have. User bots
|
||||
* that are making a lot of API requests can even be banned.</warn>
|
||||
* @param {string} tokenOrEmail The token or email used for the account. If it is an email, a password _must_ be
|
||||
* provided.
|
||||
* @param {string} [password] The password for the account, only needed if an email was provided.
|
||||
* @param {string} token The token used for the account.
|
||||
* @returns {Promise<string>}
|
||||
* @example
|
||||
* // log the client in using a token
|
||||
@@ -250,9 +236,8 @@ class Client extends EventEmitter {
|
||||
* const password = 'supersecret123';
|
||||
* client.login(email, password);
|
||||
*/
|
||||
login(tokenOrEmail, password = null) {
|
||||
if (password) return this.rest.methods.loginEmailPassword(tokenOrEmail, password);
|
||||
return this.rest.methods.loginToken(tokenOrEmail);
|
||||
login(token) {
|
||||
return this.rest.methods.login(token);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,22 +16,13 @@ class RESTMethods {
|
||||
this.rest = restManager;
|
||||
}
|
||||
|
||||
loginToken(token = this.rest.client.token) {
|
||||
login(token = this.rest.client.token) {
|
||||
return new Promise((resolve, reject) => {
|
||||
token = token.replace(/^Bot\s*/i, '');
|
||||
this.rest.client.manager.connectToWebSocket(token, resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
loginEmailPassword(email, password) {
|
||||
this.rest.client.emit('warn', 'Client launched using email and password - should use token instead');
|
||||
this.rest.client.email = email;
|
||||
this.rest.client.password = password;
|
||||
return this.rest.makeRequest('post', Constants.Endpoints.login, false, { email, password }).then(data =>
|
||||
this.loginToken(data.token)
|
||||
);
|
||||
}
|
||||
|
||||
logout() {
|
||||
return this.rest.makeRequest('post', Constants.Endpoints.logout, true, {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user