From c153056f0964fb9cc334aecad926ce1bddc6cfb7 Mon Sep 17 00:00:00 2001 From: Jareth Gomes Date: Tue, 19 Aug 2025 04:10:15 +0000 Subject: [PATCH 1/2] Fix reporter Cog to be type checked before invoking function --- bot.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index 7ab3b9a..e31efc6 100644 --- a/bot.py +++ b/bot.py @@ -47,6 +47,8 @@ class PiBotCommandTree(app_commands.CommandTree): + client: PiBot + def __init__(self, client: PiBot): super().__init__(client) @@ -95,15 +97,17 @@ async def on_error( ) elif isinstance(error, app_commands.CommandInvokeError): message = "This command experienced a general error." + if error.original: + message += f"\n{error.original}" # Report error to staff reporter_cog = self.client.get_cog("Reporter") - assert isinstance(reporter_cog, Reporter) - await reporter_cog.create_command_error_report( - error.original, - interaction.command, - ) + if isinstance(reporter_cog, Reporter): + await reporter_cog.create_command_error_report( + error.original, + interaction.command, + ) elif isinstance(error, app_commands.TransformerError): message = "This command experienced a transformer error." From 5baa854d88419571653f90a46711703c93747b7c Mon Sep 17 00:00:00 2001 From: Jareth Gomes Date: Tue, 19 Aug 2025 04:33:25 +0000 Subject: [PATCH 2/2] Add log warning for when Reporter cog type mismatch --- bot.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bot.py b/bot.py index e31efc6..2be1bea 100644 --- a/bot.py +++ b/bot.py @@ -108,6 +108,12 @@ async def on_error( error.original, interaction.command, ) + else: + logger.warning( + "Reporter cog was not of type `Reporter`. Was instead: {}".format( + type(reporter_cog), + ), + ) elif isinstance(error, app_commands.TransformerError): message = "This command experienced a transformer error."