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

feat(Rest): optional ratelimit errors #5659

Merged
merged 13 commits into from Jun 9, 2021

Conversation

Vendicated
Copy link
Contributor

Please describe the changes this PR makes and why it should be merged:
Adds new client option disableRateLimitQueue which takes either an array of routes or (ratelimitData) => boolean.
If a rate limit is hit, the RequestHandler first checks whether this rate limit should be thrown (route starts with one of the array values / function returns true) and if so throws an error instead of queueing the request

This closes #5449

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)

Copy link
Contributor

@NotSugden NotSugden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the onRateLimit function should also be added to typings

src/rest/RequestHandler.js Outdated Show resolved Hide resolved
typings/index.d.ts Outdated Show resolved Hide resolved
@Vendicated
Copy link
Contributor Author

Vendicated commented May 22, 2021

I have no idea how to look at the docs json in my browser so they are untested

@Vendicated Vendicated changed the title Ratelimit errors feat(Rest): optional ratelimit errors May 22, 2021
typings/index.d.ts Outdated Show resolved Hide resolved
src/rest/RequestHandler.js Outdated Show resolved Hide resolved
src/rest/RequestHandler.js Outdated Show resolved Hide resolved
src/util/Constants.js Outdated Show resolved Hide resolved
src/rest/RequestHandler.js Outdated Show resolved Hide resolved
src/util/Constants.js Outdated Show resolved Hide resolved
src/util/Constants.js Outdated Show resolved Hide resolved
src/rest/RequestHandler.js Outdated Show resolved Hide resolved
Vendicated and others added 2 commits May 27, 2021 08:19
@Vendicated
Copy link
Contributor Author

Is this better?

@iCrawl iCrawl requested a review from kyranet May 29, 2021 11:30
Copy link
Member

@SpaceEEC SpaceEEC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

src/rest/RequestHandler.js Outdated Show resolved Hide resolved
src/client/Client.js Outdated Show resolved Hide resolved
@iCrawl
Copy link
Member

iCrawl commented Jun 5, 2021

@Vendicated if you could apply those changes requested we can move forward with merging this.

@Vendicated
Copy link
Contributor Author

sorry, I forgot 😅

@iCrawl iCrawl requested a review from vladfrangu June 7, 2021 07:00
src/rest/RequestHandler.js Outdated Show resolved Hide resolved
@iCrawl iCrawl merged commit 16f261e into discordjs:master Jun 9, 2021
@Vendicated Vendicated deleted the ratelimit-errors branch June 9, 2021 12:17
@iCrawl iCrawl added this to the Version 13 milestone Jun 27, 2021
ckohen added a commit to ckohen/discord.js-modules that referenced this pull request Oct 25, 2021
Ported from discordjs/discord.js#5659

Co-authored-by: Ven <vendicated@riseup.net>
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
ckohen added a commit to ckohen/discord.js-modules that referenced this pull request Oct 26, 2021
Ported from discordjs/discord.js#5659

Co-authored-by: Ven <vendicated@riseup.net>
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
ckohen added a commit to ckohen/discord.js-modules that referenced this pull request Oct 30, 2021
Ported from discordjs/discord.js#5659

Co-authored-by: Ven <vendicated@riseup.net>
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
ckohen added a commit to ckohen/discord.js-modules that referenced this pull request Nov 3, 2021
Ported from discordjs/discord.js#5659

Co-authored-by: Ven <vendicated@riseup.net>
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add client option to disable automatic queueing of requests if rate limit is hit and to reject instead
7 participants