Fix context accessing to use invoked_name

This commit is contained in:
Zeva Rose 2022-05-02 10:09:17 -06:00
parent 042401c56b
commit 96ee4edf48

View file

@ -89,7 +89,7 @@ class Jarvis(Snake):
self.logger.debug(f"{add} additions, {sub} removals") self.logger.debug(f"{add} additions, {sub} removals")
async def _prerun(self, ctx: Context, *args, **kwargs) -> None: async def _prerun(self, ctx: Context, *args, **kwargs) -> None:
name = ctx.invoked_name name = ctx.invoke_target
if isinstance(ctx, InteractionContext) and ctx.target_id: if isinstance(ctx, InteractionContext) and ctx.target_id:
kwargs["context target"] = ctx.target kwargs["context target"] = ctx.target
args = " ".join(f"{k}:{v}" for k, v in kwargs.items()) args = " ".join(f"{k}:{v}" for k, v in kwargs.items())
@ -131,7 +131,7 @@ 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."""
name = ctx.invoked_name if isinstance(ctx, InteractionContext) else ctx.invoked_target name = ctx.invoke_target
self.logger.debug(f"Handling error in {name}: {error}") 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)
@ -201,7 +201,7 @@ 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."""
name = ctx.invoked_name if isinstance(ctx, InteractionContext) else ctx.invoked_target name = ctx.invoke_target
if not isinstance(ctx.channel, DMChannel) and name not in ["pw"]: if not isinstance(ctx.channel, DMChannel) and 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:
@ -225,7 +225,7 @@ class Jarvis(Snake):
fields = [ fields = [
EmbedField( EmbedField(
name="Command", name="Command",
value=f"```ansi\n{CMD_FMT}{ctx.invoked_name}{RESET} {args}\n```", value=f"```ansi\n{CMD_FMT}{ctx.invoke_target}{RESET} {args}\n```",
inline=False, inline=False,
), ),
] ]