aboutsummaryrefslogtreecommitdiffstats
path: root/botcore
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2022-06-21 19:48:36 +0200
committerGravatar Numerlor <[email protected]>2022-06-21 19:48:36 +0200
commit67003153c718925844447127f291501adddb49c0 (patch)
tree814076445e7aeab29c305d836f4e1b9f63266cff /botcore
parentstop cleanup task when manager is destroyed (diff)
ensure tuples from pos arg and kwarg tuples are differentiated
Diffstat (limited to 'botcore')
-rw-r--r--botcore/utils/cooldown.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/botcore/utils/cooldown.py b/botcore/utils/cooldown.py
index 099edba0..b9149b48 100644
--- a/botcore/utils/cooldown.py
+++ b/botcore/utils/cooldown.py
@@ -20,6 +20,8 @@ from botcore.utils.function import command_wraps
__all__ = ["CommandOnCooldown", "block_duplicate_invocations", "P", "R"]
+_KEYWORD_SEP_SENTINEL = object()
+
_ArgsList = list[object]
_HashableArgsTuple = tuple[Hashable, ...]
@@ -172,6 +174,10 @@ class _CommandCooldownManager:
self._cooldowns[key] = filtered_cooldowns
+def _create_argument_tuple(*args: object, **kwargs: object) -> Iterable[object]:
+ return (*args, _KEYWORD_SEP_SENTINEL, *kwargs.items())
+
+
def block_duplicate_invocations(
*, cooldown_duration: float = 5, send_notice: bool = False
) -> Callable[[Callable[P, Awaitable[R]]], Callable[P, Awaitable[R]]]:
@@ -194,7 +200,7 @@ def block_duplicate_invocations(
@command_wraps(func)
async def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
- arg_tuple = (*args[2:], *kwargs.items()) # skip self and ctx from the command
+ arg_tuple = _create_argument_tuple(*args[2:], **kwargs) # skip self and ctx from the command
ctx = typing.cast("Context[BotBase]", args[1])
channel = ctx.channel