mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
refactor(Util): replace Util.delayFor with tp.setTimeout (#7082)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { setTimeout: sleep } = require('node:timers/promises');
|
||||
const { AsyncQueue } = require('@sapphire/async-queue');
|
||||
const DiscordAPIError = require('./DiscordAPIError');
|
||||
const HTTPError = require('./HTTPError');
|
||||
@@ -7,7 +8,6 @@ const RateLimitError = require('./RateLimitError');
|
||||
const {
|
||||
Events: { DEBUG, RATE_LIMIT, INVALID_REQUEST_WARNING, API_RESPONSE, API_REQUEST },
|
||||
} = require('../util/Constants');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
function parseResponse(res) {
|
||||
if (res.headers.get('content-type').startsWith('application/json')) return res.json();
|
||||
@@ -145,7 +145,7 @@ class RequestHandler {
|
||||
}
|
||||
delayPromise = this.manager.globalDelay;
|
||||
} else {
|
||||
delayPromise = Util.delayFor(timeout);
|
||||
delayPromise = sleep(timeout);
|
||||
}
|
||||
|
||||
// Determine whether a RateLimitError should be thrown
|
||||
@@ -333,7 +333,7 @@ class RequestHandler {
|
||||
|
||||
// If caused by a sublimit, wait it out here so other requests on the route can be handled
|
||||
if (sublimitTimeout) {
|
||||
await Util.delayFor(sublimitTimeout);
|
||||
await sleep(sublimitTimeout);
|
||||
}
|
||||
return this.execute(request);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user