diff options
author | Parker <contact@pkrm.dev> | 2024-03-31 00:12:51 -0500 |
---|---|---|
committer | Parker <contact@pkrm.dev> | 2024-03-31 00:12:51 -0500 |
commit | 6c2311c296335864931e3044ec1474e07ff53d8b (patch) | |
tree | 4bae04e444404c9f53aaf72c7215558b35b47597 /code/cogs/clear.py | |
parent | 4a8e1001efa18110e64dc5d3f23fbd4a831333c2 (diff) |
Create `clear` command
Diffstat (limited to 'code/cogs/clear.py')
-rw-r--r-- | code/cogs/clear.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/code/cogs/clear.py b/code/cogs/clear.py new file mode 100644 index 0000000..4dded33 --- /dev/null +++ b/code/cogs/clear.py @@ -0,0 +1,37 @@ +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 Clear(commands.Cog): + def __init__(self, bot): + self.bot = bot + + + @app_commands.command() + @app_commands.check(Music.create_player) + async def clear(self, interaction: discord.Interaction): + "Clear the entire queue of songs" + player = self.bot.lavalink.player_manager.get(interaction.guild.id) + + player.queue.clear() + embed = discord.Embed( + title="Queue Cleared", + description=f"The queue has been cleared of all songs!\n\nIssued by: {interaction.user.mention}", + 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(Clear(bot)) |