Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LimitedCommand ¶
type LimitedCommand interface { // GetLimiterBurst returns the maximum amount // of tokens which can be available at a time. LimiterBurst() int // GetLimiterRestoration returns the duration // between new tokens are generated. LimiterRestoration() time.Duration // IsLimiterGlobal returns true if the limit // shall be handled globally across all guilds. // Otherwise, a limiter is created for each // guild the user executes the command on. IsLimiterGlobal() bool }
LimitedCommand specifies the structure of a rate limitable command.
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter handles and calculates the rate limit tokens using a simple token bucket system.
func NewLimiter ¶
NewLimiter initializes a new limiter with the given burst and restoration values.
type Manager ¶
type Manager interface { // GetLimiter returns a limiter instance from the given // cmd instance, userID and guildID. // // cmd is guaranteed to also implement the LimitedCommand // interface when calling this function. GetLimiter(cmd ken.Command, userID, guildID string) *Limiter }
Manager provides limiter instances by command instance, userID and guildID.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware command implements the ratelimit middleware.
Click to show internal directories.
Click to hide internal directories.