Handle prefixed contexts better

This commit is contained in:
Zeva Rose 2022-05-02 02:21:22 -06:00
parent 51b7b0add5
commit 042401c56b

View file

@ -131,7 +131,8 @@ class Jarvis(Snake):
self, ctx: Context, error: Exception, *args: list, **kwargs: dict
) -> None:
"""NAFF on_command_error override."""
self.logger.debug(f"Handling error in {ctx.invoked_name}: {error}")
name = ctx.invoked_name if isinstance(ctx, InteractionContext) else ctx.invoked_target
self.logger.debug(f"Handling error in {name}: {error}")
if isinstance(error, CommandOnCooldown):
await ctx.send(str(error), ephemeral=True)
return
@ -164,7 +165,7 @@ class Jarvis(Snake):
full_message = ERROR_MSG.format(
guild_name=ctx.guild.name,
error_time=error_time,
invoked_name=ctx.invoked_name,
invoked_name=name,
arg_str=arg_str,
callback_args=callback_args,
callback_kwargs=callback_kwargs,
@ -200,9 +201,8 @@ class Jarvis(Snake):
# Modlog
async def on_command(self, ctx: Context) -> None:
"""NAFF on_command override."""
if isinstance(ctx, PrefixedContext):
return
if not isinstance(ctx.channel, DMChannel) and ctx.invoked_name not in ["pw"]:
name = ctx.invoked_name if isinstance(ctx, InteractionContext) else ctx.invoked_target
if not isinstance(ctx.channel, DMChannel) and name not in ["pw"]:
modlog = await Setting.find_one(q(guild=ctx.guild.id, setting="activitylog"))
if modlog:
channel = await ctx.guild.fetch_channel(modlog.value)