mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
feature: allow sweeping of inactive request buckets
This commit is contained in:
@@ -13,6 +13,15 @@ class RESTManager {
|
||||
this.tokenPrefix = tokenPrefix;
|
||||
this.versioned = true;
|
||||
this.timeDifferences = [];
|
||||
if (client.options.restSweepInterval > 0) {
|
||||
client.setInterval(() => {
|
||||
for (const handler in this.handlers) {
|
||||
if (this.handlers[handler] && this.handlers[handler]._inactive) {
|
||||
this.handlers[handler] = undefined;
|
||||
}
|
||||
}
|
||||
}, client.options.restSweepInterval * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
get api() {
|
||||
|
||||
@@ -26,6 +26,13 @@ class RequestHandler {
|
||||
this.handle();
|
||||
}
|
||||
|
||||
get _inactive() {
|
||||
return this.queue.length === 0 &&
|
||||
!this.limited &&
|
||||
Date.now() > this.resetTime &&
|
||||
(typeof this.busy === 'undefined' || this.busy === false);
|
||||
}
|
||||
|
||||
execute(item) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const finish = timeout => {
|
||||
|
||||
Reference in New Issue
Block a user