* Backported OAuth2Application 201ecd25a2

* Backported retry on 500 57b6980313

* Backported b8034525e3 and fa5c4efa2b
This commit is contained in:
SpaceEEC
2017-08-21 22:25:21 +02:00
committed by Crawl
parent be4ccb3686
commit f7664b01a2
14 changed files with 304 additions and 5 deletions

View File

@@ -878,7 +878,8 @@ class RESTMethods {
}
resetApplication(id) {
return this.rest.makeRequest('post', Endpoints.OAUTH2.Application(id).reset, true)
return this.rest.makeRequest('post', Endpoints.OAUTH2.Application(id).resetToken, true)
.then(() => this.rest.makeRequest('post', Endpoints.OAUTH2.Application(id).resetSecret, true))
.then(app => new OAuth2Application(this.client, app));
}
@@ -908,6 +909,10 @@ class RESTMethods {
patchUserSettings(data) {
return this.rest.makeRequest('patch', Constants.Endpoints.User('@me').settings, true, data);
}
patchClientUserGuildSettings(guildID, data) {
return this.rest.makeRequest('patch', Constants.Endpoints.User('@me').Guild(guildID).settings, true, data);
}
}
module.exports = RESTMethods;

View File

@@ -40,6 +40,12 @@ class BurstRequestHandler extends RequestHandler {
this.handle();
this.resetTimeout = null;
}, Number(res.headers['retry-after']) + this.client.options.restTimeOffset);
} else if (err.status >= 500 && err.status < 600) {
this.queue.unshift(item);
this.resetTimeout = this.client.setTimeout(() => {
this.handle();
this.resetTimeout = null;
}, 1e3 + this.client.options.restTimeOffset);
} else {
item.reject(err.status === 400 ? new DiscordAPIError(res.body) : err);
this.handle();

View File

@@ -64,6 +64,9 @@ class SequentialRequestHandler extends RequestHandler {
resolve();
}, Number(res.headers['retry-after']) + this.restManager.client.options.restTimeOffset);
if (res.headers['x-ratelimit-global']) this.globalLimit = true;
} else if (err.status >= 500 && err.status < 600) {
this.queue.unshift(item);
this.restManager.client.setTimeout(resolve, 1e3 + this.client.options.restTimeOffset);
} else {
item.reject(err.status >= 400 && err.status < 500 ? new DiscordAPIError(res.body) : err);
resolve(err);