From a20bac72584615d13f421237285ec8147dbc9c8b Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Thu, 15 Dec 2016 10:32:19 -0600 Subject: [PATCH] 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 --- src/client/Client.js | 21 +++------------------ src/client/rest/RESTMethods.js | 11 +---------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index eccab6df5..6a06facd9 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -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. - * @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} * @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); } /** diff --git a/src/client/rest/RESTMethods.js b/src/client/rest/RESTMethods.js index 9acf62fc2..7d996deda 100644 --- a/src/client/rest/RESTMethods.js +++ b/src/client/rest/RESTMethods.js @@ -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, {}); }