Priority Global Rest Rate Limiter
An implementation of RestRateLimiter which handles the global rate limit, and in which low-priority requests are queued last to the delegate (such as application command updates).
While JDA already reads the global rate limit headers, it does not prevent doing 50+ requests on different buckets. For example, when updating commands on 50+ guilds, JDA would launch all requests in parallel, as each guild has its own bucket, resulting in a hefty rate limit.
When using this, guild commands will be updated as fast as possible, otherwise, it will be slowed down.
It is highly recommended using this (or your own implementation) with large bots.
Usage
You will need to configure the RestConfig on your DefaultShardManagerBuilder, you don't need to do this if you used a factory from JDAService (light/default/create/lightSharded/defaultSharded/createSharded).
Example:
val restConfig = RestConfig()
.setRateLimiterFactory { rlConfig: RateLimitConfig ->
PriorityGlobalRestRateLimiter(SequentialRestRateLimiter(rlConfig))
}
setRestConfig(restConfig)
Parameters
The maximum amount of permitted requests per second
The RestRateLimiter to use when submitting a request