Enforce rate limits for certain commands or modules #95

Closed
opened 2020-05-31 18:07:01 +01:00 by Ghost · 0 comments
Ghost commented 2020-05-31 18:07:01 +01:00 (Migrated from codeberg.org)

Feature Request

Description

We need a way to enforce rate limits so that users can't invoke certain commands too often. I'd love for this to be in Commandler, but I can't think of a single generic way to implement it, unless we only create the annotation and have users implement a RateLimitChecker class to be be injected at runtime.

This is required for commands that are resource heavy or incur a bill. For example if someone feels like spamming ping, we don't really care, that's on them. However, if someone is going to spam locale detect, that'll cause a problem as this is a billed API, so we want to limit it per minute or hour to a reasonable figure.

Interface

@StandardCommand
public void detectLocaleLanguage(@RateLimit(1800) @Permissions(Permission.MESSAGE_HISTORY) @Elevated @Channels(ChannelType.TEXT) Message message) {

}

The value 1800, being the number of seconds to wait before the command can be performed again. It should be possible to put the annotation on whole modules too, which will share the ratelimit across all commands in it.

# Feature Request ## Description We need a way to enforce rate limits so that users can't invoke certain commands too often. I'd love for this to be in Commandler, but I can't think of a single generic way to implement it, unless we only create the annotation and have users implement a `RateLimitChecker` class to be be injected at runtime. This is required for commands that are resource heavy or incur a bill. For example if someone feels like spamming `ping`, we don't really care, that's on them. However, if someone is going to spam `locale detect`, that'll cause a problem as this is a billed API, so we want to limit it per minute or hour to a reasonable figure. ## Interface ```java @StandardCommand public void detectLocaleLanguage(@RateLimit(1800) @Permissions(Permission.MESSAGE_HISTORY) @Elevated @Channels(ChannelType.TEXT) Message message) { } ``` The value `1800`, being the number of seconds to wait before the command can be performed again. It should be possible to put the annotation on whole modules too, which will share the ratelimit across all commands in it.
Sign in to join this conversation.
No labels
bug
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
SethFalco/alexis#95
No description provided.