From c8eb0abc9a9427945019cef6d582fa9a55a1f4e7 Mon Sep 17 00:00:00 2001 From: wookie184 Date: Sat, 10 Sep 2022 18:09:04 +0100 Subject: Check for commands being None in try_get_tag and try_silence --- bot/exts/backend/error_handler.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bot/exts/backend/error_handler.py b/bot/exts/backend/error_handler.py index 761991488..0321134ea 100644 --- a/bot/exts/backend/error_handler.py +++ b/bot/exts/backend/error_handler.py @@ -116,9 +116,13 @@ class ErrorHandler(Cog): * invoked with `unshh+` unsilence channel Return bool depending on success of command. """ + silence_command = self.bot.get_command("silence") + if not silence_command: + log.debug("Not attempting to parse message as `shh`/`unshh` as could not find `silence` command.") + return False + command = ctx.invoked_with.lower() args = ctx.message.content.lower().split(" ") - silence_command = self.bot.get_command("silence") ctx.invoked_from_error_handler = True try: @@ -164,6 +168,10 @@ class ErrorHandler(Cog): the context to prevent infinite recursion in the case of a CommandNotFound exception. """ tags_get_command = self.bot.get_command("tags get") + if not tags_get_command: + log.debug("Not attempting to parse message as a tag as could not find `tags get` command.") + return False + ctx.invoked_from_error_handler = True log_msg = "Cancelling attempt to fall back to a tag due to failed checks." -- cgit v1.2.3 From b6c2054b94c9b70fec203d370fc049bc6ac5010c Mon Sep 17 00:00:00 2001 From: wookie184 Date: Mon, 19 Sep 2022 09:08:49 +0100 Subject: Return None instead of False in try_get_tag --- bot/exts/backend/error_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/exts/backend/error_handler.py b/bot/exts/backend/error_handler.py index 0321134ea..a23d7c9fc 100644 --- a/bot/exts/backend/error_handler.py +++ b/bot/exts/backend/error_handler.py @@ -170,7 +170,7 @@ class ErrorHandler(Cog): tags_get_command = self.bot.get_command("tags get") if not tags_get_command: log.debug("Not attempting to parse message as a tag as could not find `tags get` command.") - return False + return ctx.invoked_from_error_handler = True -- cgit v1.2.3