mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
Fix feature/login (#790)
* eeeeeeee * too tired * ok gawdl3y Signed-off-by: Gus Caplan <fluffyrobotcheese@gmail.com>
This commit is contained in:
committed by
Schuyler Cebulskie
parent
5ddefc3682
commit
32eeb8ad5e
@@ -20,7 +20,7 @@ class Client extends EventEmitter {
|
|||||||
/**
|
/**
|
||||||
* @param {ClientOptions} [options] Options for the client
|
* @param {ClientOptions} [options] Options for the client
|
||||||
*/
|
*/
|
||||||
constructor(options) {
|
constructor(options = {}) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
// Obtain shard details from environment
|
// Obtain shard details from environment
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class RESTMethods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loginToken(token) {
|
loginToken(token) {
|
||||||
|
token = token.replace('Bot ', '');
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.rest.client.manager.connectToWebSocket(token, resolve, reject);
|
this.rest.client.manager.connectToWebSocket(token, resolve, reject);
|
||||||
});
|
});
|
||||||
@@ -27,7 +28,7 @@ class RESTMethods {
|
|||||||
this.rest.client.password = password;
|
this.rest.client.password = password;
|
||||||
this.rest.makeRequest('post', Constants.Endpoints.login, false, { email, password })
|
this.rest.makeRequest('post', Constants.Endpoints.login, false, { email, password })
|
||||||
.then(data => {
|
.then(data => {
|
||||||
this.rest.client.manager.connectToWebSocket(data.token, resolve, reject);
|
resolve(this.loginToken(data.token));
|
||||||
})
|
})
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user