mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
Token Caching now works
This commit is contained in:
@@ -365,7 +365,6 @@ var InternalClient = (function () {
|
||||
|
||||
var client = this.client;
|
||||
|
||||
console.log(this.tokenCacher.done);
|
||||
if (!this.tokenCacher.done) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
setTimeout(function () {
|
||||
@@ -373,7 +372,21 @@ var InternalClient = (function () {
|
||||
}, 20);
|
||||
});
|
||||
} else {
|
||||
console.log("YAA - " + this.tokenCacher.getToken(email, password));
|
||||
var tk = this.tokenCacher.getToken(email, password);
|
||||
if (tk) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
_this6.client.emit("debug", "bypassed direct API login, used cached token");
|
||||
_this6.state = _ConnectionState2["default"].LOGGED_IN;
|
||||
_this6.token = tk;
|
||||
_this6.email = email;
|
||||
_this6.password = password;
|
||||
|
||||
return _this6.getGateway().then(function (url) {
|
||||
_this6.createWS(url);
|
||||
return tk;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (this.state !== _ConnectionState2["default"].DISCONNECTED && this.state !== _ConnectionState2["default"].IDLE) {
|
||||
@@ -386,6 +399,7 @@ var InternalClient = (function () {
|
||||
email: email,
|
||||
password: password
|
||||
}).then(function (res) {
|
||||
_this6.client.emit("debug", "direct API login, cached token was unavailable");
|
||||
var token = res.token;
|
||||
_this6.tokenCacher.setToken(email, password, token);
|
||||
_this6.state = _ConnectionState2["default"].LOGGED_IN;
|
||||
|
||||
Reference in New Issue
Block a user