From 3c23802ca002bf2d0f9d3ce36841557c1b1e6fe0 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Tue, 19 Apr 2022 17:12:15 -0600 Subject: [PATCH] Fix error in tail with too large of log --- jarvis/client.py | 2 +- jarvis/cogs/botutil.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/jarvis/client.py b/jarvis/client.py index 2fb93d5..0f9e956 100644 --- a/jarvis/client.py +++ b/jarvis/client.py @@ -123,7 +123,7 @@ class Jarvis(Snake): timestamp = int(datetime.now(tz=timezone.utc).timestamp()) timestamp = f"" arg_str = "" - if ctx.target_id: + if isinstance(ctx, InteractionContext) and ctx.target_id: ctx.kwargs["context target"] = ctx.target for k, v in ctx.kwargs.items(): arg_str += f" {k}: " diff --git a/jarvis/cogs/botutil.py b/jarvis/cogs/botutil.py index 98c961a..04f9db0 100644 --- a/jarvis/cogs/botutil.py +++ b/jarvis/cogs/botutil.py @@ -26,7 +26,14 @@ class BotutilCog(Scale): if len(lines) == count + 1: lines.pop(0) log = "".join(lines) - await ctx.reply(content=f"```\n{log}\n```") + if len(log) > 1500: + with BytesIO() as file_bytes: + file_bytes.write(log.encode("UTF8")) + file_bytes.seek(0) + log = File(file_bytes, file_name=f"tail_{count}.log") + await ctx.reply(content=f"Here's the last {count} lines of the log", file=log) + else: + await ctx.reply(content=f"```\n{log}\n```") @msg_command(name="log") async def _log(self, ctx: MessageContext) -> None: