diff --git a/discord/ext/commands/cooldowns.py b/discord/ext/commands/cooldowns.py index d7fe404f9..fe9930e1d 100644 --- a/discord/ext/commands/cooldowns.py +++ b/discord/ext/commands/cooldowns.py @@ -148,6 +148,10 @@ class CooldownMapping: def valid(self): return self._cooldown is not None + @property + def type(self): + return self._type + @classmethod def from_cooldown(cls, rate, per, type): return cls(Cooldown(rate, per), type) diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 509df0578..586fb470d 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -731,7 +731,7 @@ class Command(_BaseCommand): if bucket is not None: retry_after = bucket.update_rate_limit(current) if retry_after: - raise CommandOnCooldown(bucket, retry_after) + raise CommandOnCooldown(bucket, retry_after, self._buckets.type) async def prepare(self, ctx): ctx.command = self diff --git a/discord/ext/commands/errors.py b/discord/ext/commands/errors.py index 227985f45..901a0e56c 100644 --- a/discord/ext/commands/errors.py +++ b/discord/ext/commands/errors.py @@ -460,14 +460,17 @@ class CommandOnCooldown(CommandError): Attributes ----------- cooldown: ``Cooldown`` - A class with attributes ``rate``, ``per``, and ``type`` similar to - the :func:`.cooldown` decorator. + A class with attributes ``rate`` and ``per`` similar to the + :func:`.cooldown` decorator. + type: :class:`BucketType` + The type associated with the cooldown. retry_after: :class:`float` The amount of seconds to wait before you can retry again. """ - def __init__(self, cooldown, retry_after): + def __init__(self, cooldown, retry_after, type): self.cooldown = cooldown self.retry_after = retry_after + self.type = type super().__init__(f'You are on cooldown. Try again in {retry_after:.2f}s') class MaxConcurrencyReached(CommandError):