proper fix for #1685 (#1805)

* Update WebSocketConnection.js

* Update WebSocketConnection.js

* Update WebSocketConnection.js

* Update RESTManager.js
This commit is contained in:
Gus Caplan
2017-08-19 20:14:49 -07:00
committed by Pascal
parent b79722a77b
commit af75e43900
2 changed files with 7 additions and 7 deletions

View File

@@ -16,8 +16,8 @@ class RESTManager {
} }
destroy() { destroy() {
for (const handlerID in this.handlers) { for (const handler of Object.values(this.handlers)) {
this.handlers[handlerID].destroy(); if (handler.destroy) handler.destroy();
} }
} }

View File

@@ -81,8 +81,8 @@ class WebSocketConnection extends EventEmitter {
*/ */
this.ratelimit = { this.ratelimit = {
queue: [], queue: [],
remaining: 120, remaining: 60,
resetTime: -1, resetTimer: null,
}; };
this.connect(gateway); this.connect(gateway);
@@ -190,10 +190,10 @@ class WebSocketConnection extends EventEmitter {
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 === 120) {
this.ratelimit.resetTimer = setTimeout(() => { this.ratelimit.resetTimer = this.client.setTimeout(() => {
this.ratelimit.remaining = 120; this.ratelimit.remaining = 60;
this.processQueue(); this.processQueue();
}, 120e3); // eslint-disable-line }, 120e3);
} }
while (this.ratelimit.remaining > 0) { while (this.ratelimit.remaining > 0) {
const item = this.ratelimit.queue.shift(); const item = this.ratelimit.queue.shift();