Revert "Revert "retry on 500 (#1709)""

This reverts commit 317bf4f7cb.
This commit is contained in:
Gus Caplan
2017-07-22 16:21:50 -05:00
committed by Crawl
parent 4adecf4aef
commit 91c9df2da3

View File

@@ -45,6 +45,9 @@ class RequestHandler {
if (err.status === 429) {
this.queue.unshift(item);
finish(Number(res.headers['retry-after']) + this.client.options.restTimeOffset);
} else if (err.status === 500) {
this.queue.unshift(item);
finish(1e3 + this.client.options.restTimeOffset);
} else {
item.reject(err.status >= 400 && err.status < 500 ? new DiscordAPIError(res.request.path, res.body) : err);
finish();