mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
Added option to count rate limits as errors
`options.rate_limit_as_error`
This commit is contained in:
@@ -21,6 +21,7 @@ export default class Client extends EventEmitter {
|
||||
this.options = options || {};
|
||||
this.options.compress = options.compress || true;
|
||||
this.options.revive = options.revive || false;
|
||||
this.options.rate_limit_as_error = options.rate_limit_as_error || false;
|
||||
this.internal = new InternalClient(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,13 @@ export default class InternalClient {
|
||||
ret.end((error, data) => {
|
||||
if (error) {
|
||||
error.response.error.status = 429;
|
||||
if (error.response && error.response.error && error.response.error.status && error.response.error.status === 429) {
|
||||
if (!this.client.options.rate_limit_as_error &&
|
||||
error.response &&
|
||||
error.response.error &&
|
||||
error.response.error.status
|
||||
&& error.response.error.status === 429
|
||||
) {
|
||||
|
||||
if(data.headers["retry-after"] || data.headers["Retry-After"]){
|
||||
var toWait = data.headers["retry-after"] || data.headers["Retry-After"];
|
||||
toWait = parseInt(toWait);
|
||||
@@ -76,6 +82,7 @@ export default class InternalClient {
|
||||
} else {
|
||||
return reject(error);
|
||||
}
|
||||
|
||||
} else {
|
||||
return reject(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user