question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Rate limits due to patching commands

See original GitHub issue

What happened?

After updating to Discord.js 13.7, patching slash commands will start throwing rateLimit events. Looking at the requests made, it seems you are using the singular PATCH endpoint instead of the probably intended PUT endpoint (docs here). I don’t know if the change happened with something in Discord.js or if Discord themselves started rate limiting the endpoint.

Discord.js does queue and retry the rate limited endpoints as soon as the timeout is over, so it does resolve itself, though if possible it would be preferred to use the proper batch endpoints anyway to save on requests.

In general I would consider the entirety of this logic to be flawed, as I didn’t make changes to my commands in the first place and it still tries to PATCH them, but that would be another issue.

Reproduction

  1. Have a bunch of commands (I have 34).
  2. Have a listener for the rateLimit event:
@Discord()
export abstract class ShardDisconnect {
    @On('rateLimit')
    shardDisconnect([rateLimitData]: ArgsOf<'rateLimit'>) {
        console.log(`Rate limit exceeded.`, { event: rateLimitData });
    }
}
  1. Launch the bot.
  2. The /applications/:id/commands/:id route will be repeatedly called, causing multiple rateLimits.

Package

discordx

Version

Stable

Relevant log output

warn:    ┏ Rate limit exceeded.
warn:    ┃ [ 1] {
warn:    ┃ [ 2]   event: {
warn:    ┃ [ 3]     timeout: 19748,
warn:    ┃ [ 4]     limit: 5,
warn:    ┃ [ 5]     method: 'patch',
warn:    ┃ [ 6]     path: '/applications/<snip>/commands/<snip>',
warn:    ┃ [ 7]     route: '/applications/:id/commands/:id',
warn:    ┃ [ 8]     global: false
warn:    ┃ [ 9]   }
warn:    ┗ [10] }

Code of Conduct

  • I agree to follow this project’s Code of Conduct

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
samarmeenacommented, May 14, 2022

ok, I would recommand, do not update your bot. I have finished the updates, and I will address this and release new minor version

0reactions
samarmeenacommented, May 15, 2022

oh that’s great, can we do that? can you make PR 😇

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Rate Limits - Deep Security Automation Center
API rate limits are set on /api endpoints to prevent large spikes in the number of API calls that could degrade Deep Security...
Read more >
Rate limits - GitLab Docs
The rate limit applies at the Git command (plumbing) level. Each command has a rate limit of 600 per minute. For example: git...
Read more >
Rate limits - Zoom App Marketplace
10 requests per second. Daily limit of 30,000 requests per day, shared by heavy and resource-intensive APIs. Limits to concurrent requests.
Read more >
No rate limiting flaw in cyber security - GeeksforGeeks
Rate limiting is a process to limit requests possible. ... Later, this vulnerability was patched by security experts. BUSINESS IMPACT :
Read more >
Resources in the REST API - GitHub Docs
Rate limiting. Requests from personal accounts. Requests from GitHub Apps. Requests from GitHub Actions. Checking your rate limit status.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found