diff --git a/suggestions/bot.py b/suggestions/bot.py index 44177a0..450f8d5 100644 --- a/suggestions/bot.py +++ b/suggestions/bot.py @@ -14,6 +14,7 @@ import aiohttp import alaric +import commons import disnake from alaric import Cursor from bot_base.wraps import WrappedChannel @@ -614,6 +615,13 @@ async def on_slash_command_error( ephemeral=True, ) + logger.critical( + "Unhandled error encountered", + extra_metadata={ + "error_name": exception.__class__.__name__, + "traceback": commons.exception_as_string(exception), + }, + ) raise exception async def on_button_error( diff --git a/suggestions/cogs/suggestion_cog.py b/suggestions/cogs/suggestion_cog.py index 92c2acf..222d5e5 100644 --- a/suggestions/cogs/suggestion_cog.py +++ b/suggestions/cogs/suggestion_cog.py @@ -326,7 +326,9 @@ async def suggest( ) await suggestion.setup_initial_messages( guild_config=guild_config, - ih=await InteractionHandler.new_handler(interaction), + ih=await InteractionHandler.new_handler( + interaction, i_just_want_an_instance=True + ), cog=self, guild=guild, icon_url=icon_url, diff --git a/suggestions/interaction_handler.py b/suggestions/interaction_handler.py index caabd86..1b8cbd8 100644 --- a/suggestions/interaction_handler.py +++ b/suggestions/interaction_handler.py @@ -22,15 +22,19 @@ class InteractionHandler: def __init__( self, - interaction: disnake.Interaction - | disnake.GuildCommandInteraction - | disnake.MessageInteraction, + interaction: ( + disnake.Interaction + | disnake.GuildCommandInteraction + | disnake.MessageInteraction + ), ephemeral: bool, with_message: bool, ): - self.interaction: disnake.Interaction | disnake.GuildCommandInteraction | disnake.MessageInteraction = ( - interaction - ) + self.interaction: ( + disnake.Interaction + | disnake.GuildCommandInteraction + | disnake.MessageInteraction + ) = interaction self.ephemeral: bool = ephemeral self.with_message: bool = with_message self.is_deferred: bool = False @@ -83,11 +87,17 @@ async def new_handler( *, ephemeral: bool = True, with_message: bool = True, + i_just_want_an_instance: bool = False, ) -> InteractionHandler: """Generate a new instance and defer the interaction.""" instance = cls(interaction, ephemeral, with_message) - await interaction.response.defer(ephemeral=ephemeral, with_message=with_message) - instance.is_deferred = True + + if not i_just_want_an_instance: + # TODO Remove this once BT-10 is resolved + await interaction.response.defer( + ephemeral=ephemeral, with_message=with_message + ) + instance.is_deferred = True # Register this on the bot instance so other areas can # request the interaction handler, such as error handlers