From 2cdaa11af4ce1a99d7bb51ef311a5262dd656bf1 Mon Sep 17 00:00:00 2001 From: Parker Date: Mon, 12 Aug 2024 17:30:22 -0500 Subject: [PATCH] Make sure lyrics do not exceed 4096 characters --- code/cogs/lyrics.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/code/cogs/lyrics.py b/code/cogs/lyrics.py index 135aa01..c27589e 100644 --- a/code/cogs/lyrics.py +++ b/code/cogs/lyrics.py @@ -61,9 +61,26 @@ class Lyrics(commands.Cog): lyrics = lyrics.replace("You might also like", "\n") lyrics = lyrics[:-7] + # If the lyrics are too long, send just a link to the lyrics + if len(lyrics) > 2048: + embed = discord.Embed( + title=f"Lyrics for {player.current.title} by {player.current.author}", + description=f"Song lyrics are too long to display on Discord. [Click here to view the lyrics on Genius]({song.url}).", + color=BOT_COLOR, + ) + embed.set_thumbnail(url=player.current.artwork_url) + embed.set_footer( + text=datetime.datetime.now(datetime.timezone.utc).strftime( + "%Y-%m-%d %H:%M:%S" + ) + + " UTC" + ) + return await interaction.response.send_message(embed=embed, ephemeral=True) + + # If everything is successful, send the lyrics embed = discord.Embed( title=f"Lyrics for {player.current.title} by {player.current.author}", - description=lyrics, + description=f"Provided from [Genius]({song.url})\n\n" + lyrics, color=BOT_COLOR, ) embed.set_thumbnail(url=player.current.artwork_url)