From f05dad4f5e390d561e56f93b61ee2af49adf5e91 Mon Sep 17 00:00:00 2001 From: aikaterna <20862007+aikaterna@users.noreply.github.com> Date: Mon, 25 May 2020 11:37:45 -0700 Subject: [PATCH] [Hunting] Bang task cancel --- hunting/hunting.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hunting/hunting.py b/hunting/hunting.py index de43d80..68b841e 100644 --- a/hunting/hunting.py +++ b/hunting/hunting.py @@ -11,7 +11,7 @@ from redbot.core.utils.chat_formatting import bold, box, humanize_list, humanize from redbot.core.utils.menus import menu, DEFAULT_CONTROLS -__version__ = "3.1.0" +__version__ = "3.1.1" class Hunting(commands.Cog): @@ -388,8 +388,13 @@ class Hunting(commands.Cog): int(time.mktime(datetime.datetime.utcnow().timetuple())) + wait_time ) await asyncio.sleep(wait_time) - self.bot.loop.create_task(self._wait_for_bang(message.guild, message.channel)) + task = self.bot.loop.create_task(self._wait_for_bang(message.guild, message.channel)) + self.game_tasks.append(task) try: del self.next_bang[message.guild.id] except KeyError: pass + + def cog_unload(self): + for task in self.game_tasks: + task.cancel()