aboutsummaryrefslogtreecommitdiff
path: root/code/cogs/pause.py
diff options
context:
space:
mode:
Diffstat (limited to 'code/cogs/pause.py')
-rw-r--r--code/cogs/pause.py50
1 files changed, 31 insertions, 19 deletions
diff --git a/code/cogs/pause.py b/code/cogs/pause.py
index 2b7f98d..eb3b508 100644
--- a/code/cogs/pause.py
+++ b/code/cogs/pause.py
@@ -1,10 +1,11 @@
import discord
import datetime
+from typing import Literal
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 Pause(commands.Cog):
@@ -12,28 +13,39 @@ class Pause(commands.Cog):
self.bot = bot
@app_commands.command()
+ @app_commands.describe(pause="TRUE to pause, FALSE to unpause")
@app_commands.check(Music.create_player)
- async def pause(self, interaction: discord.Interaction):
- "Pauses the song that is currently playing"
+ async def pause(
+ self, interaction: discord.Interaction, pause: Literal["TRUE", "FALSE"]
+ ):
+ "Pause or unpause the current song"
player = self.bot.lavalink.player_manager.get(interaction.guild.id)
- await player.set_pause(pause=True)
- embed = discord.Embed(
- title=f"Music Now Paused ⏸️",
- description=(
- f"**[{player.current.title}]({player.current.uri})**\n\nQueued"
- f" by: {player.current.requester.mention}"
- ),
- color=BOT_COLOR,
- )
- embed.set_thumbnail(url=player.current.artwork_url)
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
+ if pause:
+ await player.set_pause(pause=True)
+ embed = create_embed(
+ title=f"Music Paused ⏸️",
+ description=(
+ f"**[{player.current.title}]({player.current.uri})** by"
+ f" {player.current.author}\n\nQueued by:"
+ f" {player.current.requester.mention}"
+ ),
+ thumbnail=player.current.artwork_url,
)
- + " UTC"
- )
- await interaction.response.send_message(embed=embed)
+ return await interaction.response.send_message(embed=embed)
+
+ else:
+ await player.set_pause(pause=False)
+ embed = create_embed(
+ title=f"Music Unpaused ▶️",
+ description=(
+ f"**[{player.current.title}]({player.current.uri})** by"
+ f" {player.current.author}\n\nQueued by:"
+ f" {player.current.requester.mention}"
+ ),
+ thumbnail=player.current.artwork_url,
+ )
+ return await interaction.response.send_message(embed=embed)
async def setup(bot):