mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-18 23:15:48 +00:00
[commands] Allow DynamicCooldownMapping factory to return None
This commit is contained in:
parent
fd5886a058
commit
7d2e5be3a1
@ -148,11 +148,11 @@ class CooldownMapping:
|
|||||||
class DynamicCooldownMapping(CooldownMapping):
|
class DynamicCooldownMapping(CooldownMapping):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
factory: Callable[[Message], Cooldown],
|
factory: Callable[[Message], Optional[Cooldown]],
|
||||||
type: Callable[[Message], Any],
|
type: Callable[[Message], Any],
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(None, type)
|
super().__init__(None, type)
|
||||||
self._factory: Callable[[Message], Cooldown] = factory
|
self._factory: Callable[[Message], Optional[Cooldown]] = factory
|
||||||
|
|
||||||
def copy(self) -> DynamicCooldownMapping:
|
def copy(self) -> DynamicCooldownMapping:
|
||||||
ret = DynamicCooldownMapping(self._factory, self._type)
|
ret = DynamicCooldownMapping(self._factory, self._type)
|
||||||
@ -163,7 +163,7 @@ class DynamicCooldownMapping(CooldownMapping):
|
|||||||
def valid(self) -> bool:
|
def valid(self) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def create_bucket(self, message: Message) -> Cooldown:
|
def create_bucket(self, message: Message) -> Optional[Cooldown]:
|
||||||
return self._factory(message)
|
return self._factory(message)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user