Add fallback in case table is too big

This commit is contained in:
Zeva Rose 2022-05-01 10:21:55 -06:00
parent 0660a3aec9
commit 89f22db78d

View file

@ -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=[])