Handle prefixed contexts better
This commit is contained in:
parent
51b7b0add5
commit
042401c56b
1 changed files with 5 additions and 5 deletions
|
@ -131,7 +131,8 @@ class Jarvis(Snake):
|
||||||
self, ctx: Context, error: Exception, *args: list, **kwargs: dict
|
self, ctx: Context, error: Exception, *args: list, **kwargs: dict
|
||||||
) -> None:
|
) -> None:
|
||||||
"""NAFF on_command_error override."""
|
"""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):
|
if isinstance(error, CommandOnCooldown):
|
||||||
await ctx.send(str(error), ephemeral=True)
|
await ctx.send(str(error), ephemeral=True)
|
||||||
return
|
return
|
||||||
|
@ -164,7 +165,7 @@ class Jarvis(Snake):
|
||||||
full_message = ERROR_MSG.format(
|
full_message = ERROR_MSG.format(
|
||||||
guild_name=ctx.guild.name,
|
guild_name=ctx.guild.name,
|
||||||
error_time=error_time,
|
error_time=error_time,
|
||||||
invoked_name=ctx.invoked_name,
|
invoked_name=name,
|
||||||
arg_str=arg_str,
|
arg_str=arg_str,
|
||||||
callback_args=callback_args,
|
callback_args=callback_args,
|
||||||
callback_kwargs=callback_kwargs,
|
callback_kwargs=callback_kwargs,
|
||||||
|
@ -200,9 +201,8 @@ class Jarvis(Snake):
|
||||||
# Modlog
|
# Modlog
|
||||||
async def on_command(self, ctx: Context) -> None:
|
async def on_command(self, ctx: Context) -> None:
|
||||||
"""NAFF on_command override."""
|
"""NAFF on_command override."""
|
||||||
if isinstance(ctx, PrefixedContext):
|
name = ctx.invoked_name if isinstance(ctx, InteractionContext) else ctx.invoked_target
|
||||||
return
|
if not isinstance(ctx.channel, DMChannel) and name not in ["pw"]:
|
||||||
if not isinstance(ctx.channel, DMChannel) and ctx.invoked_name not in ["pw"]:
|
|
||||||
modlog = await Setting.find_one(q(guild=ctx.guild.id, setting="activitylog"))
|
modlog = await Setting.find_one(q(guild=ctx.guild.id, setting="activitylog"))
|
||||||
if modlog:
|
if modlog:
|
||||||
channel = await ctx.guild.fetch_channel(modlog.value)
|
channel = await ctx.guild.fetch_channel(modlog.value)
|
||||||
|
|
Loading…
Add table
Reference in a new issue