Browse Source
[commands] Allow DynamicCooldownMapping factory to return None
pull/7906/head
Cryptex
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
3 additions and
3 deletions
-
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) |
|
|
|
|
|
|
|
|
|
|
|