Fix error in tail with too large of log
This commit is contained in:
parent
79a50e9059
commit
3c23802ca0
2 changed files with 9 additions and 2 deletions
|
@ -123,7 +123,7 @@ class Jarvis(Snake):
|
||||||
timestamp = int(datetime.now(tz=timezone.utc).timestamp())
|
timestamp = int(datetime.now(tz=timezone.utc).timestamp())
|
||||||
timestamp = f"<t:{timestamp}:T>"
|
timestamp = f"<t:{timestamp}:T>"
|
||||||
arg_str = ""
|
arg_str = ""
|
||||||
if ctx.target_id:
|
if isinstance(ctx, InteractionContext) and ctx.target_id:
|
||||||
ctx.kwargs["context target"] = ctx.target
|
ctx.kwargs["context target"] = ctx.target
|
||||||
for k, v in ctx.kwargs.items():
|
for k, v in ctx.kwargs.items():
|
||||||
arg_str += f" {k}: "
|
arg_str += f" {k}: "
|
||||||
|
|
|
@ -26,7 +26,14 @@ class BotutilCog(Scale):
|
||||||
if len(lines) == count + 1:
|
if len(lines) == count + 1:
|
||||||
lines.pop(0)
|
lines.pop(0)
|
||||||
log = "".join(lines)
|
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")
|
@msg_command(name="log")
|
||||||
async def _log(self, ctx: MessageContext) -> None:
|
async def _log(self, ctx: MessageContext) -> None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue