mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-06 18:11:59 +00:00
[commands] Add back CommandOnCooldown.type
This commit is contained in:
parent
982140b5f7
commit
a3d7e06f25
@ -148,6 +148,10 @@ class CooldownMapping:
|
|||||||
def valid(self):
|
def valid(self):
|
||||||
return self._cooldown is not None
|
return self._cooldown is not None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self):
|
||||||
|
return self._type
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_cooldown(cls, rate, per, type):
|
def from_cooldown(cls, rate, per, type):
|
||||||
return cls(Cooldown(rate, per), type)
|
return cls(Cooldown(rate, per), type)
|
||||||
|
@ -731,7 +731,7 @@ class Command(_BaseCommand):
|
|||||||
if bucket is not None:
|
if bucket is not None:
|
||||||
retry_after = bucket.update_rate_limit(current)
|
retry_after = bucket.update_rate_limit(current)
|
||||||
if retry_after:
|
if retry_after:
|
||||||
raise CommandOnCooldown(bucket, retry_after)
|
raise CommandOnCooldown(bucket, retry_after, self._buckets.type)
|
||||||
|
|
||||||
async def prepare(self, ctx):
|
async def prepare(self, ctx):
|
||||||
ctx.command = self
|
ctx.command = self
|
||||||
|
@ -460,14 +460,17 @@ class CommandOnCooldown(CommandError):
|
|||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
cooldown: ``Cooldown``
|
cooldown: ``Cooldown``
|
||||||
A class with attributes ``rate``, ``per``, and ``type`` similar to
|
A class with attributes ``rate`` and ``per`` similar to the
|
||||||
the :func:`.cooldown` decorator.
|
:func:`.cooldown` decorator.
|
||||||
|
type: :class:`BucketType`
|
||||||
|
The type associated with the cooldown.
|
||||||
retry_after: :class:`float`
|
retry_after: :class:`float`
|
||||||
The amount of seconds to wait before you can retry again.
|
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.cooldown = cooldown
|
||||||
self.retry_after = retry_after
|
self.retry_after = retry_after
|
||||||
|
self.type = type
|
||||||
super().__init__(f'You are on cooldown. Try again in {retry_after:.2f}s')
|
super().__init__(f'You are on cooldown. Try again in {retry_after:.2f}s')
|
||||||
|
|
||||||
class MaxConcurrencyReached(CommandError):
|
class MaxConcurrencyReached(CommandError):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user