[commands] fix BucketType.default bypassing dynamic_cooldown

This commit is contained in:
Mikey
2022-04-30 15:46:37 -07:00
committed by GitHub
parent 8e9e25246e
commit 165e14063f
2 changed files with 5 additions and 2 deletions

View File

@ -2315,7 +2315,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`
@ -2348,6 +2348,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)