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.

Request: Rate limit replies

See original GitHub issue

Hey 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:closed
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Maelstromeouscommented, Feb 7, 2017

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?

0reactions
appellationcommented, Feb 23, 2019

This was implemented in #1180

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rate limit response examples - Akamai TechDocs
These examples show 429 failure responses when a URL purge request has exceeded an API request rate limit and an object rate limit....
Read more >
Rate limits | Docs | Twitter Developer Platform
The maximum number of requests that are allowed is based on a time interval, some specified period or window of time. The most...
Read more >
Rate Limits - Graph API - Meta for Developers - Facebook
A rate limit is the number of API calls an app or user can make within a given time period. If this limit...
Read more >
Best practices for avoiding rate limiting | Zendesk Developer ...
For each request, you can check to see if you've bumped into the rate limit. If you get a response code of 429,...
Read more >
Rate limit best practices - Okta Developer
The best way to be sure about org-wide rate limits is to check the relevant headers in the response. The System Log doesn't...
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