Skip to content

Commit

Permalink
proper fix for #1685 (#1805)
Browse files Browse the repository at this point in the history
* Update WebSocketConnection.js

* Update WebSocketConnection.js

* Update WebSocketConnection.js

* Update RESTManager.js
  • Loading branch information
devsnek authored and SpaceEEC committed Mar 1, 2018
1 parent b79722a commit af75e43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/client/rest/RESTManager.js
Expand Up @@ -16,8 +16,8 @@ class RESTManager {
}

destroy() {
for (const handlerID in this.handlers) {
this.handlers[handlerID].destroy();
for (const handler of Object.values(this.handlers)) {
if (handler.destroy) handler.destroy();
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/client/websocket/WebSocketConnection.js
Expand Up @@ -81,8 +81,8 @@ class WebSocketConnection extends EventEmitter {
*/
this.ratelimit = {
queue: [],
remaining: 120,
resetTime: -1,
remaining: 60,
resetTimer: null,
};
this.connect(gateway);

Expand Down Expand Up @@ -190,10 +190,10 @@ class WebSocketConnection extends EventEmitter {
if (this.ratelimit.remaining === 0) return;
if (this.ratelimit.queue.length === 0) return;
if (this.ratelimit.remaining === 120) {
this.ratelimit.resetTimer = setTimeout(() => {
this.ratelimit.remaining = 120;
this.ratelimit.resetTimer = this.client.setTimeout(() => {
this.ratelimit.remaining = 60;
this.processQueue();
}, 120e3); // eslint-disable-line
}, 120e3);
}
while (this.ratelimit.remaining > 0) {
const item = this.ratelimit.queue.shift();
Expand Down

0 comments on commit af75e43

Please sign in to comment.