From 89f22db78ddc355b9ae4fbc48d7baf988bf46779 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Sun, 1 May 2022 10:21:55 -0600 Subject: [PATCH] Add fallback in case table is too big --- jarvis/cogs/botutil.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jarvis/cogs/botutil.py b/jarvis/cogs/botutil.py index bec04c7..806ce0b 100644 --- a/jarvis/cogs/botutil.py +++ b/jarvis/cogs/botutil.py @@ -8,6 +8,7 @@ import git import psutil from aiofile import AIOFile, LineReader from dis_snek import MessageContext, Scale, Snake +from dis_snek.client.errors import BadRequest from dis_snek.client.utils.misc_utils import find from dis_snek.models.discord.embed import EmbedField from dis_snek.models.discord.file import File @@ -176,10 +177,11 @@ class BotutilCog(Scale): ) table.add_row("Total", str(i_total), str(d_total), str(l_total)) - self.logger.debug(table) console = Console() with console.capture() as capture: console.print(table) + self.logger.debug(capture.get()) + self.logger.debug(len(capture.get())) new = "\n".join(loaded) removed = "\n".join(unloaded) changed = "\n".join(reloaded) @@ -201,7 +203,10 @@ class BotutilCog(Scale): embed.set_image(url="https://dev.zevaryx.com/git.png") self.logger.info("Updates applied") - await ctx.reply(f"```ansi\n{capture.get()}\n```", embed=embed) + try: + await ctx.reply(f"```ansi\n{capture.get()}\n```", embed=embed) + except BadRequest: + await ctx.reply(f"Total Changes: {l_total}", embed=embed) else: embed = build_embed(title="Update Status", description="No changes applied", fields=[])