From 7d2e5be3a135112e1b3d3cb6310de0ff089874ea Mon Sep 17 00:00:00 2001 From: Cryptex <64497526+Cryptex-github@users.noreply.github.com> Date: Mon, 18 Apr 2022 22:25:40 -0700 Subject: [PATCH] [commands] Allow DynamicCooldownMapping factory to return None --- discord/ext/commands/cooldowns.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/discord/ext/commands/cooldowns.py b/discord/ext/commands/cooldowns.py index 52e125cba..534658728 100644 --- a/discord/ext/commands/cooldowns.py +++ b/discord/ext/commands/cooldowns.py @@ -148,11 +148,11 @@ class CooldownMapping: class DynamicCooldownMapping(CooldownMapping): def __init__( self, - factory: Callable[[Message], Cooldown], + factory: Callable[[Message], Optional[Cooldown]], type: Callable[[Message], Any], ) -> None: super().__init__(None, type) - self._factory: Callable[[Message], Cooldown] = factory + self._factory: Callable[[Message], Optional[Cooldown]] = factory def copy(self) -> DynamicCooldownMapping: ret = DynamicCooldownMapping(self._factory, self._type) @@ -163,7 +163,7 @@ class DynamicCooldownMapping(CooldownMapping): def valid(self) -> bool: return True - def create_bucket(self, message: Message) -> Cooldown: + def create_bucket(self, message: Message) -> Optional[Cooldown]: return self._factory(message)