From 4903406f79439a9b642763841c067a2a6aa22d5f Mon Sep 17 00:00:00 2001 From: Parker Date: Sun, 31 Mar 2024 02:14:29 -0500 Subject: [PATCH] Black code reformat --- code/cogs/repeat.py | 79 +++++++++++++++++++++++++++++++++++++++++++++ code/cogs/skip.py | 2 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 code/cogs/repeat.py diff --git a/code/cogs/repeat.py b/code/cogs/repeat.py new file mode 100644 index 0000000..71460b7 --- /dev/null +++ b/code/cogs/repeat.py @@ -0,0 +1,79 @@ +import discord +import datetime +from discord import app_commands +from discord.ext import commands +from cogs.music import Music + +from global_variables import BOT_COLOR + + +class Repeat(commands.GroupCog, name="repeat"): + def __init__(self, bot): + self.bot = bot + + @app_commands.command(name="off") + @app_commands.check(Music.create_player) + async def repeat_off(self, interaction: discord.Interaction): + "Turn song/queue repetition off" + player = self.bot.lavalink.player_manager.get(interaction.guild.id) + + 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" + ) + await interaction.response.send_message(embed=embed) + + @app_commands.command(name="song") + @app_commands.check(Music.create_player) + async def repeat_song(self, interaction: discord.Interaction): + "Forever repeat that song that is currently playing" + player = self.bot.lavalink.player_manager.get(interaction.guild.id) + + player.loop = 1 + + embed = discord.Embed( + title=f"Repeating Current Song 🔁", + description=f"The song that is currently playing will be repeated until the `/repeat off` 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) + + @app_commands.command(name="queue") + @app_commands.check(Music.create_player) + async def repeat_queue(self, interaction: discord.Interaction): + "Continuously repeat the queue once it reaches the end" + player = self.bot.lavalink.player_manager.get(interaction.guild.id) + + player.loop = 2 + + embed = discord.Embed( + title=f"Repeating Current Song 🔂", + description=f"All songs in the queue will continue to repeat until the `/repeat off` 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) + + +async def setup(bot): + await bot.add_cog(Repeat(bot)) diff --git a/code/cogs/skip.py b/code/cogs/skip.py index ca7f3e0..eca27b5 100644 --- a/code/cogs/skip.py +++ b/code/cogs/skip.py @@ -45,7 +45,7 @@ class Skip(commands.Cog): embed = discord.Embed( title="End of Queue", description=f"All songs in queue have been played. Thank you for using Guava :wave:\n\nIssued by: {interaction.user.mention}", - color=BOT_COLOR + color=BOT_COLOR, ) return await interaction.response.send_message(embed=embed)