do away with sing embeds globally

This commit is contained in:
codey 2025-03-29 06:41:03 -04:00
parent 436755f884
commit 4f3c82f9c0
2 changed files with 21 additions and 35 deletions

View File

@ -91,32 +91,23 @@ class Sing(commands.Cog):
short_lyrics = " ".join(search_result_wrapped_short) # Replace with shortened lyrics for non spamchans short_lyrics = " ".join(search_result_wrapped_short) # Replace with shortened lyrics for non spamchans
short_lyrics = regex.sub(r'\p{Vert_Space}', ' / ', short_lyrics.strip()) short_lyrics = regex.sub(r'\p{Vert_Space}', ' / ', short_lyrics.strip())
return await ctx.respond(f"**{search_result_song}** by **{search_result_artist}**\n-# {short_lyrics}") return await ctx.respond(f"**{search_result_song}** by **{search_result_artist}**\n-# {short_lyrics}")
embeds: list[Optional[discord.Embed]] = []
embed_url: str = f"[on codey.lol](https://codey.lol/#{urllib.parse.quote(search_artist)}/{urllib.parse.quote(search_song)})"
c: int = 0 c: int = 0
footer: str = "To be continued..." #Placeholder out_messages: list = []
footer: str = "" # Placeholder
for section in search_result_wrapped: for section in search_result_wrapped:
c+=1 c+=1
if c == len(search_result_wrapped): if c == len(search_result_wrapped):
footer = f"Found on: {search_result_src}" footer = f"Found on: {search_result_src}"
section = self.control_strip_regex.sub('', section)
# if ctx.guild.id == 1145182936002482196: # if ctx.guild.id == 1145182936002482196:
# section = section.upper() # section = section.upper()
embed: discord.Embed = discord.Embed( section = regex.sub(r'\p{Vert_Space}', ' / ', section.strip())
title=f"{search_result_song} by {search_result_artist}", msg: str = f"**{search_result_song}** by **{search_result_artist}**\n-# {section}\n{footer}"
description=discord.utils.escape_markdown(section) if c > 1:
) msg = "\n".join(msg.split("\n")[1:])
embed.add_field(name="Confidence", value=search_result_confidence, out_messages.append(msg.strip())
inline=True) for msg in out_messages:
embed.add_field(name="Time Taken", value=search_result_time_taken, await ctx.send(msg)
inline=True)
embed.add_field(name="Link", value=embed_url)
embed.set_footer(text=footer)
embeds.append(embed)
await ctx.respond(embed=embeds[0])
for _embed in embeds[1:]:
if isinstance(_embed, discord.Embed):
await ctx.send(embed=_embed)
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
await ctx.respond(f"ERR: {str(e)}") await ctx.respond(f"ERR: {str(e)}")
@ -176,27 +167,22 @@ class Sing(commands.Cog):
short_lyrics = regex.sub(r'\p{Vert_Space}', ' / ', short_lyrics.strip()) short_lyrics = regex.sub(r'\p{Vert_Space}', ' / ', short_lyrics.strip())
return await ctx.respond(f"**{search_result_song}** by **{search_result_artist}**\n-# {short_lyrics}") return await ctx.respond(f"**{search_result_song}** by **{search_result_artist}**\n-# {short_lyrics}")
embeds: list[Optional[discord.Embed]] = [] out_messages: list = []
footer: str = ""
c: int = 0 c: int = 0
footer: str = "To be continued..." #Placeholder
for section in search_result_wrapped: for section in search_result_wrapped:
c+=1 c+=1
if c == len(search_result_wrapped): if c == len(search_result_wrapped):
footer = f"Found on: {search_result_src}" footer = f"Found on: {search_result_src}"
# if ctx.guild.id == 1145182936002482196: # if ctx.guild.id == 1145182936002482196:
# section = section.upper() # section = section.upper()
embed: discord.Embed = discord.Embed( section = regex.sub(r'\p{Vert_Space}', ' / ', section.strip())
title=f"{search_result_song} by {search_result_artist}", msg: str = f"**{search_result_song}** by **{search_result_artist}**\n-# {section}\n{footer}"
description=discord.utils.escape_markdown(section) if c > 1:
) msg = "\n".join(msg.split("\n")[1:])
embed.add_field(name="Confidence", value=search_result_confidence, inline=True) out_messages.append(msg.strip())
embed.add_field(name="Time Taken", value=search_result_time_taken, inline=True) for msg in out_messages:
embed.add_field(name="Link", value=f"[on codey.lol](https://codey.lol/#{urllib.parse.quote(search_result_artist)}/{urllib.parse.quote(search_result_song)})") await ctx.send(msg)
embed.set_footer(text=footer)
embeds.append(embed)
for _embed in embeds:
await ctx.send(embed=_embed)
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
return await ctx.respond(f"ERR: {str(e)}") return await ctx.respond(f"ERR: {str(e)}")

View File

@ -130,7 +130,7 @@ class Utility:
if not lyrics: if not lyrics:
return None return None
response_obj['lyrics'] = textwrap.wrap(text=lyrics.strip(), response_obj['lyrics'] = textwrap.wrap(text=lyrics.strip(),
width=4000, drop_whitespace=False, width=1500, drop_whitespace=False,
replace_whitespace=False, break_long_words=True, replace_whitespace=False, break_long_words=True,
break_on_hyphens=True, max_lines=8) break_on_hyphens=True, max_lines=8)
response_obj['lyrics_short'] = textwrap.wrap(text=lyrics.strip(), response_obj['lyrics_short'] = textwrap.wrap(text=lyrics.strip(),