cooldown
Function
Rate-limits a command: @cooldown(1, 5) allows one use every 5 seconds per user.
from discord_interactions import cooldownSignature
def cooldown( rate: int = 1, per: float = 5.0, type: CooldownType = CooldownType.USER, bucket_key: Callable[[discord.Interaction], str] | None = None,) -> CallableParameters
| Name | Type | Default | Description |
|---|---|---|---|
rate | int | 1 | Number of uses in the window. |
per | float | 5.0 | Window length in seconds. |
type | CooldownType | CooldownType.USER | Scope: user, member, guild, channel, category, role, global or custom. |
bucket_key | Callable[[discord.Interaction], str] | None | None | Custom key (interaction) -> str. |
Returns
Callable
Example
from discord_interactions.slash import CooldownType, cooldown @slash.command(description="Récompense quotidienne")@cooldown(1, 86_400, type=CooldownType.MEMBER)async def quotidien(ctx): await ctx.respond("+100 pièces")