Add support and logging for rate limiting to prevent APIs being called and surpassing the rate limit.
https://discord.com/developers/docs/topics/rate-limits#rate-limits
For the gateway API rate limiting restricts a bot to 120 gateway events per connection every 60 seconds - exceeding this disconnects the bot and eventually will get the bot banned.
For the REST API there is a global rate limit and endpoint rate limits - endpoint rate limits are returned by the endpoint in its response header and need to be stored to determine rate limits. If a rate limit is hit a 429 response code will be returned.
The global rate limit for a bot is 50 requests per second - this is only really a problem for large bots which will require sharding, in the use case of the one I'm making I do not think this currently needs considering.
Rate limiting therefore needs to be handled on a for-each basis
Add support and logging for rate limiting to prevent APIs being called and surpassing the rate limit.
https://discord.com/developers/docs/topics/rate-limits#rate-limits
For the gateway API rate limiting restricts a bot to 120 gateway events per connection every 60 seconds - exceeding this disconnects the bot and eventually will get the bot banned.
For the REST API there is a global rate limit and endpoint rate limits - endpoint rate limits are returned by the endpoint in its response header and need to be stored to determine rate limits. If a rate limit is hit a 429 response code will be returned.
The global rate limit for a bot is 50 requests per second - this is only really a problem for large bots which will require sharding, in the use case of the one I'm making I do not think this currently needs considering.
Rate limiting therefore needs to be handled on a for-each basis