discord.js
discord.js copied to clipboard
Request handler doesn't fire the ratelimit event on sublimits
Which package is this bug report for?
discord.js
Issue description
When I try to change the channel name more than twice, The third request status returns 429 but the rate limit won't emit, And the request handler should queue the third and prevent hitting the sublimity. for more info check this thread on discord.js server

Code sample
const client = new Client();
client.on('debug', info => console.log(info));
client.on('rateLimit', (rateLimitData) => console.log(rateLimitData));
await client.login(token);
Package version
13.8.1
Node.js version
17.9.1
Operating system
Linux (debian)
Priority this issue should have
High (immediate attention needed)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
Guilds, GuildMembers, GuildMessages
I have tested this issue on a development release
No response
expected behavior:

The rateLimit event is fired when discord.js preemptively blocks a request from hitting a rate limit, not when we encounter an actual ratelimit. By the time a request is re-queued the ratelimit may have already expired.
Sublimits are a bit of an interesting case. Because we can't properly track the requests ratelimit data we need to stall sublimited requests manually. In this case it may seem pertinent to emit the event manually too. However, I'd rather suggest a new event sublimitted or similar.
The rateLimit event is fired when discord.js preemptively blocks a request from hitting a rate limit, not when we encounter an actual ratelimit. By the time a request is re-queued the ratelimit may have already expired.
Sublimits are a bit of an interesting case. Because we can't properly track the requests ratelimit data we need to stall sublimited requests manually. In this case it may seem pertinent to emit the event manually too. However, I'd rather suggest a new event
sublimittedor similar.
yeah I know that rateLimit event is emited when d.js blocks a request from hitting a rate limit but we need the same behavior in sublimits to prevent the client from hitting the rate limit.
That's not how sublimits work, we don't know about them until we hit them, and even then we don't know what combination of parameters cauesd it. We get no information about it other than when to retry