mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 17:43:30 +01:00
refactor: remove timer utilities from Client (#6113)
This commit is contained in:
@@ -59,14 +59,14 @@ class APIRequest {
|
||||
}
|
||||
|
||||
const controller = new AbortController();
|
||||
const timeout = this.client.setTimeout(() => controller.abort(), this.client.options.restRequestTimeout);
|
||||
const timeout = setTimeout(() => controller.abort(), this.client.options.restRequestTimeout).unref();
|
||||
return fetch(url, {
|
||||
method: this.method,
|
||||
headers,
|
||||
agent,
|
||||
body,
|
||||
signal: controller.signal,
|
||||
}).finally(() => this.client.clearTimeout(timeout));
|
||||
}).finally(() => clearTimeout(timeout));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,9 @@ class RESTManager {
|
||||
this.globalReset = null;
|
||||
this.globalDelay = null;
|
||||
if (client.options.restSweepInterval > 0) {
|
||||
const interval = client.setInterval(() => {
|
||||
this.sweepInterval = setInterval(() => {
|
||||
this.handlers.sweep(handler => handler._inactive);
|
||||
}, client.options.restSweepInterval * 1000);
|
||||
interval.unref();
|
||||
}, client.options.restSweepInterval * 1000).unref();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,10 +71,10 @@ class RequestHandler {
|
||||
|
||||
globalDelayFor(ms) {
|
||||
return new Promise(resolve => {
|
||||
this.manager.client.setTimeout(() => {
|
||||
setTimeout(() => {
|
||||
this.manager.globalDelay = null;
|
||||
resolve();
|
||||
}, ms);
|
||||
}, ms).unref();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user