From 0fd5eca0d57c3dc49c84ebd0222288ea323b137b Mon Sep 17 00:00:00 2001 From: Steve C Date: Wed, 6 May 2020 15:35:41 -0400 Subject: [PATCH] [tasks] Fix tasks decorators being discarded At this moment, when a task seems to be first loaded, it immediately throws away the decorators you give it, and just generates a new instance of itself. In your cog's `__init__`, once you do `self.my_task.start()`, the Loop is remade when it gets to `self.my_task` before executing the `start` function. The original Loop that the cog starts with is where the decorated values are. This fixes that. --- discord/ext/tasks/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index c95d28534..36cfe8104 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -109,6 +109,9 @@ class Loop: copy = Loop(self.coro, seconds=self.seconds, hours=self.hours, minutes=self.minutes, count=self.count, reconnect=self.reconnect, loop=self.loop) copy._injected = obj + copy._before_loop = self._before_loop + copy._after_loop = self._after_loop + copy._error = self._error setattr(obj, self.coro.__name__, copy) return copy