diff options
author | Parker <contact@pkrm.dev> | 2024-08-12 22:31:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-12 22:31:28 +0000 |
commit | d134bc06d37e6589c58f2847d7e35f9bab9939ab (patch) | |
tree | 131b8c5bb98dd723d3de6810ee2c578a7489029d /code | |
parent | 727130dc1a5f157091918a77dbbc977d5c2d1223 (diff) | |
parent | 2cdaa11af4ce1a99d7bb51ef311a5262dd656bf1 (diff) |
Merge pull request #4 from PacketParker/dev
Make sure lyrics do not exceed 4096 characters
Diffstat (limited to 'code')
-rw-r--r-- | code/cogs/lyrics.py | 19 |
1 files changed, 18 insertions, 1 deletions
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) |