[commands] Add back CommandOnCooldown.type
This commit is contained in:
		| @@ -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) | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user