Skip to content
Merged
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
5 changes: 4 additions & 1 deletion src/rest/sequentialBucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ export class SequentialBucket {
if (res.status >= 400 && res.status < 500) {
const data: any = await parseResponse(res);
if (res.status === 429) {
if (attempts >= this.#handler.options.retryLimit!)
throw new DiscordRESTError(request, res, data, stackHolder.stack);

const delay = data?.retry_after ? data.retry_after * 1000 : retryAfter;
this.#handler.creator?.emit(
'debug',
Expand All @@ -187,7 +190,7 @@ export class SequentialBucket {

if (delay) await Mutex.wait(delay);

return this.#execute(request, attempts);
return this.#execute(request, ++attempts);
}

throw new DiscordRESTError(request, res, data, stackHolder.stack);
Expand Down
Loading