From e73db927c17866793293868d915bf0e37a906737 Mon Sep 17 00:00:00 2001 From: Parker Date: Thu, 28 Nov 2024 00:41:33 -0600 Subject: 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 --- code/cogs/remove.py | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'code/cogs/remove.py') diff --git a/code/cogs/remove.py b/code/cogs/remove.py index f672ffd..bba07a4 100644 --- a/code/cogs/remove.py +++ b/code/cogs/remove.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 Remove(commands.Cog): @@ -19,26 +19,15 @@ class Remove(commands.Cog): player = self.bot.lavalink.player_manager.get(interaction.guild.id) if not player.queue: - embed = discord.Embed( + embed = create_embed( title="Nothing Queued", - description=( - "Nothing is currently in the queue, so there is nothing" - " for me to remove." - ), - color=BOT_COLOR, - ) - embed.set_footer( - text=datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%d %H:%M:%S" - ) - + " UTC" + description="There are no songs in the queue to remove.", ) return await interaction.response.send_message(embed=embed) if number > len(player.queue) or number < 1: return await interaction.response.send_message( - "The number entered is not a number within the queue - please" - " try again!", + "Number out of range - please try again!", ephemeral=True, ) @@ -48,21 +37,14 @@ class Remove(commands.Cog): removed_artwork = player.queue[index].artwork_url player.queue.pop(index) - embed = discord.Embed( + embed = create_embed( title="Song Removed from Queue", description=( "**Song Removed -" f" [{removed_title}]({removed_url})**\n\nIssued by:" f" {interaction.user.mention}" ), - color=BOT_COLOR, - ) - embed.set_thumbnail(url=removed_artwork) - embed.set_footer( - text=datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%d %H:%M:%S" - ) - + " UTC" + thumbnail=removed_artwork, ) await interaction.response.send_message(embed=embed) -- cgit v1.2.3-70-g09d2