Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase delay less aggressively on rate limit #419

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/deleteMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ async function deleteMessages(authToken, authorId, guildId, channelId, minId, ma
const w = (await resp.json()).retry_after * 1000;
throttledCount++;
throttledTotalTime += w;
searchDelay += w; // increase delay
log.warn(`Being rate limited by the API for ${w}ms! Increasing search delay...`);
searchDelay += 50; // increase delay
log.warn(`Being rate limited by the API for ${w}ms! Adjusted search delay to ${searchDelay}ms.`);
printDelayStats();
log.verb(`Cooling down for ${w * 2}ms before retrying...`);

Expand Down Expand Up @@ -182,7 +182,7 @@ async function deleteMessages(authToken, authorId, guildId, channelId, minId, ma
const w = (await resp.json()).retry_after * 1000;
throttledCount++;
throttledTotalTime += w;
deleteDelay = w; // increase delay
deleteDelay += 50; // increase delay
log.warn(`Being rate limited by the API for ${w}ms! Adjusted delete delay to ${deleteDelay}ms.`);
printDelayStats();
log.verb(`Cooling down for ${w * 2}ms before retrying...`);
Expand Down Expand Up @@ -222,4 +222,4 @@ async function deleteMessages(authToken, authorId, guildId, channelId, minId, ma
return await recurse();
}

export default deleteMessages;
export default deleteMessages;