Request: Rate limit replies
See original GitHub issueHey Discord.js devs!
I’d like to open a discussion regarding adding the ability for the end user to see their rate limit information to the main Discord API system.
A common concern amongst a few Discord.js developers (including myself) is that we’re in fear of potentially getting rate limited.
So, upon sending any kind of request to Discord.js, we ideally should get a response as we normally do, but attached to said response should be a limit remaining and reset time.
Now I understand that all of Discord.js is based on a promise system, so a using a .then
should allow us to return an object with the response of the request and the rate limit information.
Alternatively, this could be set as a bot event, which will allow us to automatically, with very little extra code to our client applications, to update our rate limit information. I reckon this should be an opt in feature upon bot start (so you essentially “subscribe” to this rate limit information) so that you’re not sending unnessessary traffic to the API.
My concept:
bot.on('ready', () => {
bot.subscribeToRateLimits(true);
});
bot.on('rateLimits', (info) => {
updateRateLimitInfo(info);
});
And the event contains the message:
{
"status": "ok", # Or "limited" when rate limited
"remaining": "123456",
"reset_after": "14000000", # timestamp
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (3 by maintainers)
Ahh that’s good to know then so basically it means the responsibility of managing the rate limit is done on the DiscordJS side, so we don’t have to worry about it?
This was implemented in #1180