[Bug]: Rate limits due to patching commands
See original GitHub issueWhat 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
- Have a bunch of commands (I have 34).
- 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 });
}
}
- Launch the bot.
- The
/applications/:id/commands/:id
route will be repeatedly called, causing multiplerateLimit
s.
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:
- Created a year ago
- Comments:10 (10 by maintainers)
ok, I would recommand, do not update your bot. I have finished the updates, and I will address this and release new minor version
oh that’s great, can we do that? can you make PR 😇