aboutsummaryrefslogtreecommitdiff
path: root/code/cogs/lyrics.py
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-11-28 00:41:33 -0600
committerParker <contact@pkrm.dev>2024-11-28 00:41:33 -0600
commite73db927c17866793293868d915bf0e37a906737 (patch)
treee05843e8e4af9b672731a435e8bd8a1f559bece9 /code/cogs/lyrics.py
parent1ce91a4b0984407bcd08b4fbf7448d7f4dbcead2 (diff)
Create `create_embed` template to replace `discord.Embed()`
- Auto-set color to BOT_COLOR - Set footer to timestamp (overridden is timestamp is passed) - Optional thumbnail
Diffstat (limited to 'code/cogs/lyrics.py')
-rw-r--r--code/cogs/lyrics.py44
1 files changed, 8 insertions, 36 deletions
diff --git a/code/cogs/lyrics.py b/code/cogs/lyrics.py
index e28d2c2..6e3a1d3 100644
--- a/code/cogs/lyrics.py
+++ b/code/cogs/lyrics.py
@@ -4,7 +4,7 @@ from discord import app_commands
from discord.ext import commands
from cogs.music import Music
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class Lyrics(commands.Cog):
@@ -19,19 +19,12 @@ class Lyrics(commands.Cog):
# If the Genius API client is not setup, send an error message
if not self.bot.genius:
- embed = discord.Embed(
+ embed = create_embed(
title="Lyrics Feature Error",
description=(
"The lyrics feature is currently disabled due to errors"
" with the Genius API."
),
- color=BOT_COLOR,
- )
- 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
@@ -48,20 +41,13 @@ class Lyrics(commands.Cog):
# If no lyrics are found, send an error message
if song is None:
- embed = discord.Embed(
+ embed = create_embed(
title="Lyrics Not Found",
description=(
"Unfortunately, I wasn't able to find any lyrics for the"
" song that is currently playing."
),
- 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"
+ thumbnail=player.current.artwork_url,
)
return await interaction.edit_original_response(embed=embed)
@@ -73,7 +59,7 @@ class Lyrics(commands.Cog):
# If the lyrics are too long, send just a link to the lyrics
if len(lyrics) > 2048:
- embed = discord.Embed(
+ embed = create_embed(
title=(
f"Lyrics for {player.current.title} by"
f" {player.current.author}"
@@ -82,31 +68,17 @@ class Lyrics(commands.Cog):
"Song lyrics are too long to display on Discord. [Click"
f" 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"
+ thumbnail=player.current.artwork_url,
)
return await interaction.edit_original_response(embed=embed)
# If everything is successful, send the lyrics
- embed = discord.Embed(
+ embed = create_embed(
title=(
f"Lyrics for {player.current.title} by {player.current.author}"
),
description=f"Provided from [Genius]({song.url})\n\n" + lyrics,
- 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"
+ thumbnail=player.current.artwork_url,
)
await interaction.edit_original_response(embed=embed)