From f14139dc8ff7ef6e64444757c2b7057b8d54a847 Mon Sep 17 00:00:00 2001 From: Mikey <8661717+sgtlaggy@users.noreply.github.com> Date: Sat, 30 Apr 2022 15:46:37 -0700 Subject: [PATCH] [commands] fix BucketType.default bypassing dynamic_cooldown --- discord/ext/commands/core.py | 5 ++++- docs/ext/commands/api.rst | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 325c3fa18..8101f28ce 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -2304,7 +2304,7 @@ def cooldown( def dynamic_cooldown( cooldown: Union[BucketType, Callable[[Message], Any]], - type: BucketType = BucketType.default, + type: BucketType, ) -> Callable[[T], T]: """A decorator that adds a dynamic cooldown to a :class:`.Command` @@ -2337,6 +2337,9 @@ def dynamic_cooldown( if not callable(cooldown): 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]: if isinstance(func, Command): func._buckets = DynamicCooldownMapping(cooldown, type) diff --git a/docs/ext/commands/api.rst b/docs/ext/commands/api.rst index c8029c31f..12612c8e9 100644 --- a/docs/ext/commands/api.rst +++ b/docs/ext/commands/api.rst @@ -296,7 +296,7 @@ Checks .. autofunction:: discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default) :decorator: -.. autofunction:: discord.ext.commands.dynamic_cooldown(cooldown, type=BucketType.default) +.. autofunction:: discord.ext.commands.dynamic_cooldown(cooldown, type) :decorator: .. autofunction:: discord.ext.commands.max_concurrency(number, per=discord.ext.commands.BucketType.default, *, wait=False)