aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-03-31 00:12:03 -0500
committerParker <contact@pkrm.dev>2024-03-31 00:12:03 -0500
commit472271f94211c954fe2ca158a0aa9976b0f706a1 (patch)
treee6d8c2e0e1847b32f4363d5e6edf8fcbce8cafc7
parent86d9a9a770103903561c91cd96c44aa47466e2af (diff)
Create `stop` command
-rw-r--r--code/cogs/stop.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/code/cogs/stop.py b/code/cogs/stop.py
new file mode 100644
index 0000000..eb3341b
--- /dev/null
+++ b/code/cogs/stop.py
@@ -0,0 +1,40 @@
+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 Stop(commands.Cog):
+ def __init__(self, bot):
+ self.bot = bot
+
+
+ @app_commands.command()
+ @app_commands.check(Music.create_player)
+ async def stop(self, interaction: discord.Interaction):
+ "Disconnects the bot from the voice channel and clears the queue"
+ player = self.bot.lavalink.player_manager.get(interaction.guild.id)
+
+ player.queue.clear()
+ await player.stop()
+ await interaction.guild.voice_client.disconnect(force=True)
+
+ embed = discord.Embed(
+ title="Queue Cleared and Music Stopped",
+ description=f"Thank you for using Guava :wave:\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(Stop(bot))