fix(seautils): fixed body error
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 40s

This commit is contained in:
Seaswimmer 2024-05-28 21:54:48 -04:00
parent 861a03719b
commit 2d895d16c9
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -208,28 +208,21 @@ class SeaUtils(commands.Cog):
html = await response.text() html = await response.text()
soup = BeautifulSoup(html, 'html.parser') soup = BeautifulSoup(html, 'html.parser')
pre_tags = soup.find_all('pre') pre_tags = soup.find_all('pre')
content = [] content: list[Embed | str] = []
for pre_tag in pre_tags: for pre_tag in pre_tags:
text = convert_rfc_references(md(pre_tag), number) text = convert_rfc_references(md(pre_tag), number)
if len(text) > 4096: if len(text) > 4096:
text1 = text[:4096] pagified_text = cf.pagify(text, delims=["\n\n"], page_length=4096)
text2 = text[4096:] for page in pagified_text:
if await ctx.embed_requested(): if await ctx.embed_requested():
embed = Embed( embed = Embed(
title=f"RFC Document {number}", title=f"RFC Document {number}",
description=text1, description=page,
color=await ctx.embed_color() color=await ctx.embed_color()
) )
content.append(embed) content.append(embed)
embed2 = Embed( else:
title=f"RFC Document {number}", content.append(page)
description=text2,
color=await ctx.embed_color()
)
content.append(embed2)
else:
content.append(text1)
content.append(text2)
else: else:
if await ctx.embed_requested(): if await ctx.embed_requested():
embed = Embed( embed = Embed(
@ -240,6 +233,9 @@ class SeaUtils(commands.Cog):
content.append(embed) content.append(embed)
else: else:
content.append(text) 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) await SimpleMenu(pages=content, disable_after_timeout=True, timeout=300).start(ctx)
else: else:
await ctx.maybe_send_embed(content=cf.error(f"An error occurred while fetching RFC {number}. Status code: {response.status}.")) await ctx.maybe_send_embed(content=cf.error(f"An error occurred while fetching RFC {number}. Status code: {response.status}."))