fix(seautils): fixed body error

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

View file

@ -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:]
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=text1,
description=page,
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)
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}."))