From 9827d6eeaf191fb4cd8a144388804617922f50f4 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 23 Feb 2019 07:41:25 -0500 Subject: [PATCH] [commands] Fix issue with decorator order with checks and cooldowns Now they're just explicitly copied. --- discord/ext/commands/cooldowns.py | 5 +++++ discord/ext/commands/core.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/discord/ext/commands/cooldowns.py b/discord/ext/commands/cooldowns.py index ae48b284b..9687d5f6c 100644 --- a/discord/ext/commands/cooldowns.py +++ b/discord/ext/commands/cooldowns.py @@ -98,6 +98,11 @@ class CooldownMapping: self._cache = {} self._cooldown = original + def copy(self): + ret = CooldownMapping(self._cooldown) + ret._cache = self._cache.copy() + return ret + @property def valid(self): return self._cooldown is not None diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index b980b92ff..45c3eb80e 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -268,6 +268,10 @@ class Command(_BaseCommand): ret = self.__class__(self.callback, **self.__original_kwargs__) ret._before_invoke = self._before_invoke ret._after_invoke = self._after_invoke + if self.checks != ret.checks: + ret.checks = self.checks.copy() + if self._buckets != ret._buckets: + ret._buckets = self._buckets.copy() try: ret.on_error = self.on_error except AttributeError: