From 87e3b18a77cd303f20bdf298e55c5305d52f1f11 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Wed, 30 Mar 2022 10:13:18 -0600 Subject: [PATCH] Better command logging --- jarvis/client.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jarvis/client.py b/jarvis/client.py index bae626e..410dc17 100644 --- a/jarvis/client.py +++ b/jarvis/client.py @@ -73,8 +73,10 @@ class Jarvis(Snake): if update["domain"] in self.phishing_domains: self.phishing_domains.remove(update["domain"]) - async def _prerun(self, ctx: Context, *args, **kwargs) -> None: + async def _prerun(self, ctx: InteractionContext, *args, **kwargs) -> None: name = ctx.invoked_name + if ctx.target: + kwargs["context target"] = ctx.target args = " ".join(f"{k}:{v}" for k, v in kwargs.items()) self.logger.debug(f"Running command `{name}` with args: {args or 'None'}") @@ -115,6 +117,8 @@ class Jarvis(Snake): timestamp = int(datetime.now().timestamp()) timestamp = f"" arg_str = "" + if ctx.target: + ctx.kwargs["context target"] = ctx.target for k, v in ctx.kwargs.items(): arg_str += f" {k}: " if isinstance(v, str) and len(v) > 100: @@ -136,8 +140,8 @@ class Jarvis(Snake): error_message = "\n ".join(error_message.split("\n")) full_message += "Exception: |\n " + error_message paste = Paste(content=full_message, site=DEFAULT_SITE) - await paste.save() - self.logger.debug(f"Large traceback, saved to Pasty {paste.id}") + key = await paste.save() + self.logger.debug(f"Large traceback, saved to Pasty {paste.id}, {key=}") await channel.send( f"JARVIS encountered an error at {timestamp}. Log too big to send over Discord." @@ -160,6 +164,8 @@ class Jarvis(Snake): if modlog: channel = await ctx.guild.fetch_channel(modlog.value) args = [] + if ctx.target: + args.append(f"{KEY_FMT}context target:{VAL_FMT}{ctx.target}{RESET}") for k, v in ctx.kwargs.items(): if isinstance(v, str): v = v.replace("`", "\\`")