From 2d895d16c9eaba1c56313a591f77859f7eb8d707 Mon Sep 17 00:00:00 2001 From: Seaswimmer Date: Tue, 28 May 2024 21:54:48 -0400 Subject: [PATCH] fix(seautils): fixed body error --- seautils/seautils.py | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/seautils/seautils.py b/seautils/seautils.py index fd6f25b..6b2618a 100644 --- a/seautils/seautils.py +++ b/seautils/seautils.py @@ -208,28 +208,21 @@ class SeaUtils(commands.Cog): html = await response.text() soup = BeautifulSoup(html, 'html.parser') pre_tags = soup.find_all('pre') - content = [] + content: list[Embed | str] = [] for pre_tag in pre_tags: text = convert_rfc_references(md(pre_tag), number) if len(text) > 4096: - text1 = text[:4096] - text2 = text[4096:] - if await ctx.embed_requested(): - embed = Embed( - title=f"RFC Document {number}", - description=text1, - color=await ctx.embed_color() - ) - content.append(embed) - embed2 = Embed( - title=f"RFC Document {number}", - description=text2, - color=await ctx.embed_color() - ) - content.append(embed2) - else: - content.append(text1) - content.append(text2) + pagified_text = cf.pagify(text, delims=["\n\n"], page_length=4096) + for page in pagified_text: + if await ctx.embed_requested(): + embed = Embed( + title=f"RFC Document {number}", + description=page, + color=await ctx.embed_color() + ) + content.append(embed) + else: + content.append(page) else: if await ctx.embed_requested(): embed = Embed( @@ -240,6 +233,9 @@ class SeaUtils(commands.Cog): content.append(embed) else: content.append(text) + if await ctx.embed_requested(): + for embed in content: + embed.set_footer(text=f"Page {content.index(embed) + 1}/{len(content)}") await SimpleMenu(pages=content, disable_after_timeout=True, timeout=300).start(ctx) else: await ctx.maybe_send_embed(content=cf.error(f"An error occurred while fetching RFC {number}. Status code: {response.status}."))