From 3458bf4b1a95c33ddc899633b9925c3f0fe4aff8 Mon Sep 17 00:00:00 2001 From: Bahaa <62975113+bahaa32@users.noreply.github.com> Date: Tue, 4 Jul 2023 16:37:52 -0700 Subject: [PATCH] Do not adjust delay if retry_after < delay --- src/undiscord-core.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/undiscord-core.js b/src/undiscord-core.js index 955467f2..017805e5 100644 --- a/src/undiscord-core.js +++ b/src/undiscord-core.js @@ -390,8 +390,11 @@ class UndiscordCore { const w = (await resp.json()).retry_after * 1000; this.stats.throttledCount++; this.stats.throttledTotalTime += w; - this.options.deleteDelay = w; // increase delay - log.warn(`Being rate limited by the API for ${w}ms! Adjusted delete delay to ${this.options.deleteDelay}ms.`); + log.warn(`Being rate limited by the API for ${w}ms!`); + if (this.options.deleteDelay < w) { + this.options.deleteDelay = w; // increase delay + log.warn(`Adjusted delete delay to ${this.options.deleteDelay}ms.`); + } this.printStats(); log.verb(`Cooling down for ${w * 2}ms before retrying...`); await wait(w * 2);