Webpack build for branch master: cd54e9317f

This commit is contained in:
Travis CI 2017-10-27 13:45:08 +00:00
parent 7d96d29213
commit 428e6899c6
2 changed files with 14 additions and 5 deletions

View file

@ -13324,12 +13324,22 @@ class RESTManager {
this.globallyRateLimited = false;
this.tokenPrefix = tokenPrefix;
this.versioned = true;
this.timeDifferences = [];
}
get api() {
return routeBuilder(this);
}
get timeDifference() {
return Math.round(this.timeDifferences.reduce((a, b) => a + b, 0) / this.timeDifferences.length);
}
set timeDifference(ms) {
this.timeDifferences.unshift(ms);
if (this.timeDifferences.length > 5) this.timeDifferences.length = 5;
}
getAuth() {
const token = this.client.token || this.client.accessToken;
const prefixed = !!this.client.application || (this.client.user && this.client.user.bot);
@ -13444,7 +13454,6 @@ class RequestHandler {
this.limit = Infinity;
this.resetTime = null;
this.remaining = 1;
this.timeDifference = 0;
this.queue = [];
}
@ -13467,7 +13476,7 @@ class RequestHandler {
const finish = timeout => {
if (timeout || this.limited) {
if (!timeout) {
timeout = this.resetTime - Date.now() + this.timeDifference + this.client.options.restTimeOffset;
timeout = this.resetTime - Date.now() + this.manager.timeDifference + this.client.options.restTimeOffset;
}
// eslint-disable-next-line prefer-promise-reject-errors
reject({ timeout });
@ -13485,7 +13494,7 @@ class RequestHandler {
this.client.emit(RATE_LIMIT, {
timeout,
limit: this.limit,
timeDifference: this.timeDifference,
timeDifference: this.manager.timeDifference,
method: item.request.method,
path: item.request.path,
route: item.request.route,
@ -13501,7 +13510,7 @@ class RequestHandler {
this.limit = Number(res.headers['x-ratelimit-limit']);
this.resetTime = Number(res.headers['x-ratelimit-reset']) * 1000;
this.remaining = Number(res.headers['x-ratelimit-remaining']);
this.timeDifference = Date.now() - new Date(res.headers.date).getTime();
this.manager.timeDifference = Date.now() - new Date(res.headers.date).getTime();
}
if (err) {
if (err.status === 429) {

File diff suppressed because one or more lines are too long