Example #1
0
 async def invoke_and_catch(self, interaction: InteractionCommand):
     try:
         command = interaction.command
         if isinstance(command, ApplicationCommand):
             tag = self.get_tag(interaction.guild, command.id)
             await self.process_tag(interaction, tag)
         elif interaction.command_id == self.eval_command:
             await self.slash_eval(interaction)
         else:
             log.debug("Unknown interaction created:\n%r", interaction)
     except Exception as e:
         raise commands.CommandInvokeError(e) from e
Example #2
0
 async def on_slash_interaction(self, interaction: InteractionCommand):
     try:
         command = interaction.command
         if isinstance(command, SlashCommand):
             tag = self.get_tag(interaction.guild, command.id)
             await self.process_tag(interaction, tag)
         elif interaction.command_id == self.eval_command:
             await self.slash_eval(interaction)
         else:
             log.debug("Unknown interaction created:\n%r" % interaction)
     except Exception as e:
         ctx = SlashContext.from_interaction(interaction)
         self.bot.dispatch("command_error", ctx,
                           commands.CommandInvokeError(e))
Example #3
0
 async def slash_command_parser(self, data: dict):
     try:
         interaction = InteractionResponse(data=data, cog=self)
     except Exception as e:
         log.exception(
             f"An exception occured while parsing an interaction:\n{data}", exc_info=e
         )
         return
     try:
         await self.handle_interaction(interaction)
     except Exception as e:
         log.exception(
             f"An exception occured while handling an interaction:\n{data}", exc_info=e
         )
         ctx = SlashContext.from_interaction(interaction)
         self.bot.dispatch("command_error", ctx, commands.CommandInvokeError(e))