Skip to content

Commit

Permalink
Use retryAfterMs if available
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed Jun 7, 2024
1 parent f875bf3 commit eb928ed
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/commands/InviteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,13 @@ export class InviteCommand implements ICommand {
++invitesSent;
} catch (e) {
if (e.statusCode === 429) {
// HACK Retry after ratelimits
await sleep(301_000);
// Retry after ratelimits
// Add 1 second to the ratelimit just to ensure we don't retry too quickly
// due to clock drift or a very small requested wait.
// If no retry time set, use 5 minutes.
let delay = (e.retryAfterMs ?? 300_000) + 1_000;

await sleep(delay);
continue;
}
LogService.error("InviteCommand", e);
Expand Down

0 comments on commit eb928ed

Please sign in to comment.