RateLimit

annotation class RateLimit(val scope: RateLimitScope, val deleteOnRefill: Boolean = true, val bandwidths: Bandwidth)(source)

Defines a rate limit for a command / component handler.

Text commands note: This applies to the command itself, not only this variation, in other words, this applies to all commands with the same path.

Rate limit cancellation

The rate limit can be cancelled inside the command with CancellableRateLimit.cancelRateLimit on your event.

Example

@RateLimit(
scope = RateLimitScope.USER, bandwidths = {
@Bandwidth(capacity = 5, refill = @Refill(type = RefillType.GREEDY, tokens = 5, period = 1, periodUnit = ChronoUnit.MINUTES)),
@Bandwidth(capacity = 2, refill = @Refill(type = RefillType.INTERVAL, tokens = 2, period = 5, periodUnit = ChronoUnit.SECONDS))
})
@JDASlashCommand(...)
public void onSlashRateLimit(...) { ... }

See also

Properties

Link copied to clipboard
Link copied to clipboard

Whether the rate limit message should be deleted after the rate limit has expired.

Link copied to clipboard

Scope of the rate limit, see RateLimitScope values.