forked from cswimr/SeaCogs
misc(seautils): optimized showcode
This commit is contained in:
parent
bb1aca83dd
commit
84d2728d3a
1 changed files with 4 additions and 7 deletions
|
@ -38,19 +38,16 @@ class SeaUtils(commands.Cog):
|
||||||
async def showcode(self, ctx: commands.Context, *, command: str):
|
async def showcode(self, ctx: commands.Context, *, command: str):
|
||||||
"""Show the code for a particular command."""
|
"""Show the code for a particular command."""
|
||||||
try:
|
try:
|
||||||
temp_content = []
|
temp_content = cf.pagify(
|
||||||
content = []
|
|
||||||
for page in cf.pagify(
|
|
||||||
text=inspect.getsource(self.bot.get_command(command).callback),
|
text=inspect.getsource(self.bot.get_command(command).callback),
|
||||||
escape_mass_mentions=True,
|
escape_mass_mentions=True,
|
||||||
page_length = 1977
|
page_length = 1977
|
||||||
):
|
)
|
||||||
temp_content.append(cf.box(page, lang='py'))
|
content = []
|
||||||
|
|
||||||
max_i = len(temp_content)
|
max_i = len(temp_content)
|
||||||
i = 1
|
i = 1
|
||||||
for page in temp_content:
|
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
|
i += 1
|
||||||
await SimpleMenu(content, disable_after_timeout=True, timeout=180).start(ctx)
|
await SimpleMenu(content, disable_after_timeout=True, timeout=180).start(ctx)
|
||||||
except (OSError, AttributeError):
|
except (OSError, AttributeError):
|
||||||
|
|
Loading…
Reference in a new issue