mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23:31 +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;
|
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
|
* The ClientUser representing the logged in Client
|
||||||
* @type {?ClientUser}
|
* @type {?ClientUser}
|
||||||
@@ -236,9 +224,7 @@ class Client extends EventEmitter {
|
|||||||
* much better to use a bot account rather than a user account.
|
* 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
|
* 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>
|
* 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
|
* @param {string} token The token used for the account.
|
||||||
* provided.
|
|
||||||
* @param {string} [password] The password for the account, only needed if an email was provided.
|
|
||||||
* @returns {Promise<string>}
|
* @returns {Promise<string>}
|
||||||
* @example
|
* @example
|
||||||
* // log the client in using a token
|
* // log the client in using a token
|
||||||
@@ -250,9 +236,8 @@ class Client extends EventEmitter {
|
|||||||
* const password = 'supersecret123';
|
* const password = 'supersecret123';
|
||||||
* client.login(email, password);
|
* client.login(email, password);
|
||||||
*/
|
*/
|
||||||
login(tokenOrEmail, password = null) {
|
login(token) {
|
||||||
if (password) return this.rest.methods.loginEmailPassword(tokenOrEmail, password);
|
return this.rest.methods.login(token);
|
||||||
return this.rest.methods.loginToken(tokenOrEmail);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,22 +16,13 @@ class RESTMethods {
|
|||||||
this.rest = restManager;
|
this.rest = restManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
loginToken(token = this.rest.client.token) {
|
login(token = this.rest.client.token) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
token = token.replace(/^Bot\s*/i, '');
|
token = token.replace(/^Bot\s*/i, '');
|
||||||
this.rest.client.manager.connectToWebSocket(token, resolve, reject);
|
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() {
|
logout() {
|
||||||
return this.rest.makeRequest('post', Constants.Endpoints.logout, true, {});
|
return this.rest.makeRequest('post', Constants.Endpoints.logout, true, {});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user