mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-17 11:19:00 +00:00
[commands] fix BucketType.default bypassing dynamic_cooldown
This commit is contained in:
parent
8e9e25246e
commit
165e14063f
@ -2315,7 +2315,7 @@ def cooldown(
|
|||||||
|
|
||||||
def dynamic_cooldown(
|
def dynamic_cooldown(
|
||||||
cooldown: Union[BucketType, Callable[[Message], Any]],
|
cooldown: Union[BucketType, Callable[[Message], Any]],
|
||||||
type: BucketType = BucketType.default,
|
type: BucketType,
|
||||||
) -> Callable[[T], T]:
|
) -> Callable[[T], T]:
|
||||||
"""A decorator that adds a dynamic cooldown to a :class:`.Command`
|
"""A decorator that adds a dynamic cooldown to a :class:`.Command`
|
||||||
|
|
||||||
@ -2348,6 +2348,9 @@ def dynamic_cooldown(
|
|||||||
if not callable(cooldown):
|
if not callable(cooldown):
|
||||||
raise TypeError("A callable must be provided")
|
raise TypeError("A callable must be provided")
|
||||||
|
|
||||||
|
if type is BucketType.default:
|
||||||
|
raise ValueError('BucketType.default cannot be used in dynamic cooldowns')
|
||||||
|
|
||||||
def decorator(func: Union[Command, CoroFunc]) -> Union[Command, CoroFunc]:
|
def decorator(func: Union[Command, CoroFunc]) -> Union[Command, CoroFunc]:
|
||||||
if isinstance(func, Command):
|
if isinstance(func, Command):
|
||||||
func._buckets = DynamicCooldownMapping(cooldown, type)
|
func._buckets = DynamicCooldownMapping(cooldown, type)
|
||||||
|
@ -356,7 +356,7 @@ Checks
|
|||||||
.. autofunction:: discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)
|
.. autofunction:: discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)
|
||||||
:decorator:
|
:decorator:
|
||||||
|
|
||||||
.. autofunction:: discord.ext.commands.dynamic_cooldown(cooldown, type=BucketType.default)
|
.. autofunction:: discord.ext.commands.dynamic_cooldown(cooldown, type)
|
||||||
:decorator:
|
:decorator:
|
||||||
|
|
||||||
.. autofunction:: discord.ext.commands.max_concurrency(number, per=discord.ext.commands.BucketType.default, *, wait=False)
|
.. autofunction:: discord.ext.commands.max_concurrency(number, per=discord.ext.commands.BucketType.default, *, wait=False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user