mirror of
https://github.com/danbulant/discord.js
synced 2026-07-08 04:31:05 +00:00
fix ratelimits (#1806)
This commit is contained in:
parent
8c855855cd
commit
8b8a365e99
1 changed files with 4 additions and 2 deletions
|
|
@ -82,6 +82,7 @@ class WebSocketConnection extends EventEmitter {
|
||||||
this.ratelimit = {
|
this.ratelimit = {
|
||||||
queue: [],
|
queue: [],
|
||||||
remaining: 60,
|
remaining: 60,
|
||||||
|
total: 60,
|
||||||
resetTimer: null,
|
resetTimer: null,
|
||||||
};
|
};
|
||||||
this.connect(gateway);
|
this.connect(gateway);
|
||||||
|
|
@ -190,9 +191,9 @@ class WebSocketConnection extends EventEmitter {
|
||||||
processQueue() {
|
processQueue() {
|
||||||
if (this.ratelimit.remaining === 0) return;
|
if (this.ratelimit.remaining === 0) return;
|
||||||
if (this.ratelimit.queue.length === 0) return;
|
if (this.ratelimit.queue.length === 0) return;
|
||||||
if (this.ratelimit.remaining === 120) {
|
if (this.ratelimit.remaining === this.ratelimit.total) {
|
||||||
this.ratelimit.resetTimer = this.client.setTimeout(() => {
|
this.ratelimit.resetTimer = this.client.setTimeout(() => {
|
||||||
this.ratelimit.remaining = 60;
|
this.ratelimit.remaining = this.ratelimit.total;
|
||||||
this.processQueue();
|
this.processQueue();
|
||||||
}, 120e3);
|
}, 120e3);
|
||||||
}
|
}
|
||||||
|
|
@ -276,6 +277,7 @@ class WebSocketConnection extends EventEmitter {
|
||||||
this.packetManager.handleQueue();
|
this.packetManager.handleQueue();
|
||||||
this.ws = null;
|
this.ws = null;
|
||||||
this.status = Constants.Status.DISCONNECTED;
|
this.status = Constants.Status.DISCONNECTED;
|
||||||
|
this.ratelimit.remaining = this.ratelimit.total;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue