From 84d2728d3af54d430f99d3dd70ef5f26d836a1b5 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Mon, 13 May 2024 21:11:15 -0400 Subject: [PATCH] misc(seautils): optimized showcode --- seautils/seautils.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/seautils/seautils.py b/seautils/seautils.py index 374d28e..b9f9ef8 100644 --- a/seautils/seautils.py +++ b/seautils/seautils.py @@ -38,19 +38,16 @@ class SeaUtils(commands.Cog): async def showcode(self, ctx: commands.Context, *, command: str): """Show the code for a particular command.""" try: - temp_content = [] - content = [] - for page in cf.pagify( + temp_content = cf.pagify( text=inspect.getsource(self.bot.get_command(command).callback), escape_mass_mentions=True, page_length = 1977 - ): - temp_content.append(cf.box(page, lang='py')) - + ) + content = [] max_i = len(temp_content) i = 1 for page in temp_content: - content.append(f"**Page {i}/{max_i}**\n{page}") + content.append(f"**Page {i}/{max_i}**\n{cf.box(page, lang='py')}") i += 1 await SimpleMenu(content, disable_after_timeout=True, timeout=180).start(ctx) except (OSError, AttributeError):