Utilize console.capture to get raw table text

This commit is contained in:
Zeva Rose 2022-05-01 10:02:04 -06:00
parent 573e697ab4
commit a6a7d5ec18

View file

@ -12,6 +12,7 @@ from dis_snek.client.utils.misc_utils import find
from dis_snek.models.discord.embed import EmbedField from dis_snek.models.discord.embed import EmbedField
from dis_snek.models.discord.file import File from dis_snek.models.discord.file import File
from molter import msg_command from molter import msg_command
from rich.console import Console
from rich.table import Table from rich.table import Table
from jarvis.utils import build_embed, get_all_commands from jarvis.utils import build_embed, get_all_commands
@ -175,6 +176,9 @@ class BotutilCog(Scale):
) )
table.add_row("Total", str(i_total), str(d_total), str(l_total)) table.add_row("Total", str(i_total), str(d_total), str(l_total))
console = Console()
with console.capture() as capture:
console.print(table)
new = "\n".join(loaded) new = "\n".join(loaded)
removed = "\n".join(unloaded) removed = "\n".join(unloaded)
changed = "\n".join(reloaded) changed = "\n".join(reloaded)
@ -192,7 +196,7 @@ class BotutilCog(Scale):
) )
self.logger.info("Updates applied") self.logger.info("Updates applied")
await ctx.reply(f"File Changes: ```ansi\n{table}\n```", embed=embed) await ctx.reply(f"File Changes: ```ansi\n{capture}\n```", embed=embed)
else: else:
embed = build_embed(title="Update Status", description="No changes applied", fields=[]) embed = build_embed(title="Update Status", description="No changes applied", fields=[])