From a94c996e612fa1dea04d6cf6f3c8bb9580f3b2b7 Mon Sep 17 00:00:00 2001 From: Alex <58824393+vertyco@users.noreply.github.com> Date: Thu, 27 Oct 2022 13:35:03 -0400 Subject: [PATCH] next_bang cleanup (#293) * next_bang cleanup fix unused next_bang reference, added AttributeError exception catch when deleting next bang if message object loses guild attribute and becomes None * version Co-authored-by: aikaterna <20862007+aikaterna@users.noreply.github.com> --- hunting/hunting.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hunting/hunting.py b/hunting/hunting.py index f9f071e..35d82ca 100644 --- a/hunting/hunting.py +++ b/hunting/hunting.py @@ -14,7 +14,7 @@ from redbot.core.utils.chat_formatting import (bold, box, humanize_list, from redbot.core.utils.menus import DEFAULT_CONTROLS, menu from redbot.core.utils.predicates import MessagePredicate -__version__ = "3.1.8" +__version__ = "3.1.9" class Hunting(commands.Cog): @@ -208,8 +208,8 @@ class Hunting(commands.Cog): async def next(self, ctx): """When will the next occurrence happen?""" try: - self.next_bang[ctx.guild.id] - time = abs(datetime.datetime.utcnow() - self.next_bang[ctx.guild.id]) + hunt = self.next_bang[ctx.guild.id] + time = abs(datetime.datetime.utcnow() - hunt) total_seconds = int(time.total_seconds()) hours, remainder = divmod(total_seconds, 60 * 60) minutes, seconds = divmod(remainder, 60) @@ -480,7 +480,7 @@ class Hunting(commands.Cog): self.game_tasks.append(task) try: del self.next_bang[message.guild.id] - except KeyError: + except (KeyError, AttributeError): pass def cog_unload(self):