[commands] allow arbitrary callables in cooldown

This commit is contained in:
Mikey
2021-03-28 03:31:51 -07:00
committed by GitHub
parent baa1ab058b
commit d61486278f
2 changed files with 11 additions and 5 deletions

View File

@@ -1959,8 +1959,11 @@ def cooldown(rate, per, type=BucketType.default):
The number of times a command can be used before triggering a cooldown.
per: :class:`float`
The amount of seconds to wait for a cooldown when it's been triggered.
type: :class:`.BucketType`
The type of cooldown to have.
type: Union[:class:`.BucketType`, Callable[[:class:`.Message`], Any]]
The type of cooldown to have. If callable, should return a key for the mapping.
.. versionchanged:: 1.7
Callables are now supported for custom bucket types.
"""
def decorator(func):