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/repeat.py | 86 +++++++++++++---------------------------------------- 1 file changed, 21 insertions(+), 65 deletions(-) (limited to 'code/cogs/repeat.py') diff --git a/code/cogs/repeat.py b/code/cogs/repeat.py index cf745d5..39aaadb 100644 --- a/code/cogs/repeat.py +++ b/code/cogs/repeat.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 Repeat(commands.GroupCog, name="repeat"): @@ -18,16 +18,9 @@ class Repeat(commands.GroupCog, name="repeat"): player = self.bot.lavalink.player_manager.get(interaction.guild.id) if player.loop == 0: - embed = discord.Embed( - title=f"Repeating Already Off", - description=f"Music repetition is already turned off.", - color=BOT_COLOR, - ) - embed.set_footer( - text=datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%d %H:%M:%S" - ) - + " UTC" + embed = create_embed( + title="Repeating Already Off", + description="Music repetition is already turned off.", ) return await interaction.response.send_message( embed=embed, ephemeral=True @@ -35,16 +28,9 @@ class Repeat(commands.GroupCog, name="repeat"): player.loop = 0 - embed = discord.Embed( - title=f"Repeating Off", - description=f"Music will no longer be repeated.", - color=BOT_COLOR, - ) - embed.set_footer( - text=datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%d %H:%M:%S" - ) - + " UTC" + embed = create_embed( + title="Repeating Off", + description="Music will no longer be repeated.", ) await interaction.response.send_message(embed=embed) @@ -55,36 +41,21 @@ class Repeat(commands.GroupCog, name="repeat"): player = self.bot.lavalink.player_manager.get(interaction.guild.id) if player.loop == 1: - embed = discord.Embed( - title=f"Repeating Already On", - description=f"The current song is already being repeated.", - color=BOT_COLOR, - ) - embed.set_footer( - text=datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%d %H:%M:%S" - ) - + " UTC" + embed = create_embed( + title="Repeating Already On", + description="The current song is already being repeated.", ) return await interaction.response.send_message( embed=embed, ephemeral=True ) player.loop = 1 - - embed = discord.Embed( - title=f"Repeating Current Song 🔁", + embed = create_embed( + title="Repeating Current Song 🔁", description=( - f"The song that is currently playing will be repeated until" - f" the command is run" + "The song that is currently playing will be repeated until" + " the command is run" ), - color=BOT_COLOR, - ) - embed.set_footer( - text=datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%d %H:%M:%S" - ) - + " UTC" ) await interaction.response.send_message(embed=embed) @@ -95,36 +66,21 @@ class Repeat(commands.GroupCog, name="repeat"): player = self.bot.lavalink.player_manager.get(interaction.guild.id) if player.loop == 2: - embed = discord.Embed( - title=f"Repeating Already On", - description=f"The queue is already being repeated.", - color=BOT_COLOR, - ) - embed.set_footer( - text=datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%d %H:%M:%S" - ) - + " UTC" + embed = create_embed( + title="Repeating Already On", + description="The queue is already being repeated.", ) return await interaction.response.send_message( embed=embed, ephemeral=True ) player.loop = 2 - - embed = discord.Embed( - title=f"Repeating Current Song 🔂", + embed = create_embed( + title="Repeating Queue 🔂", description=( - f"All songs in the queue will continue to repeat until the" - f" command is run." + "The queue will continuously repeat until the" + " command is run." ), - color=BOT_COLOR, - ) - embed.set_footer( - text=datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%d %H:%M:%S" - ) - + " UTC" ) await interaction.response.send_message(embed=embed) -- cgit v1.2.3-70-g09d2 From d34726947d567ea92d105101711b04263e78cc80 Mon Sep 17 00:00:00 2001 From: Parker Date: Fri, 29 Nov 2024 00:27:38 -0600 Subject: Remove unneeded checks/messages --- code/cogs/repeat.py | 31 +++---------------------------- test.py | 14 +++----------- 2 files changed, 6 insertions(+), 39 deletions(-) (limited to 'code/cogs/repeat.py') diff --git a/code/cogs/repeat.py b/code/cogs/repeat.py index 39aaadb..50c241d 100644 --- a/code/cogs/repeat.py +++ b/code/cogs/repeat.py @@ -17,20 +17,11 @@ class Repeat(commands.GroupCog, name="repeat"): "Turn song/queue repetition off" player = self.bot.lavalink.player_manager.get(interaction.guild.id) - if player.loop == 0: - embed = create_embed( - title="Repeating Already Off", - description="Music repetition is already turned off.", - ) - return await interaction.response.send_message( - embed=embed, ephemeral=True - ) - player.loop = 0 embed = create_embed( title="Repeating Off", - description="Music will no longer be repeated.", + description="Music will not be repeated.", ) await interaction.response.send_message(embed=embed) @@ -40,16 +31,8 @@ class Repeat(commands.GroupCog, name="repeat"): "Forever repeat that song that is currently playing" player = self.bot.lavalink.player_manager.get(interaction.guild.id) - if player.loop == 1: - embed = create_embed( - title="Repeating Already On", - description="The current song is already being repeated.", - ) - return await interaction.response.send_message( - embed=embed, ephemeral=True - ) - player.loop = 1 + embed = create_embed( title="Repeating Current Song 🔁", description=( @@ -65,16 +48,8 @@ class Repeat(commands.GroupCog, name="repeat"): "Continuously repeat the queue once it reaches the end" player = self.bot.lavalink.player_manager.get(interaction.guild.id) - if player.loop == 2: - embed = create_embed( - title="Repeating Already On", - description="The queue is already being repeated.", - ) - return await interaction.response.send_message( - embed=embed, ephemeral=True - ) - player.loop = 2 + embed = create_embed( title="Repeating Queue 🔂", description=( diff --git a/test.py b/test.py index 8b4d325..bbfe23b 100644 --- a/test.py +++ b/test.py @@ -1,11 +1,3 @@ -import datetime - -now = datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%d %H:%M:%S" -) - -import time - -print(now) -time.sleep(2) -print(now) +while not Exception: + print("Test") + Exception -- cgit v1.2.3-70-g09d2