From 3c3256a9a1a2c9f8ec78d723a77fc110cab738e0 Mon Sep 17 00:00:00 2001 From: Dysta Date: Thu, 19 Sep 2024 20:54:45 +0000 Subject: [PATCH] feat: add interactive command text to embed --- jukebot/cogs/queue.py | 2 +- jukebot/services/music/current_song_service.py | 5 ++++- jukebot/services/music/resume_service.py | 15 ++++++++++----- jukebot/utils/embed.py | 9 ++++++--- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/jukebot/cogs/queue.py b/jukebot/cogs/queue.py index 8333e5d..faa734d 100644 --- a/jukebot/cogs/queue.py +++ b/jukebot/cogs/queue.py @@ -45,7 +45,7 @@ async def show(self, inter: CommandInteraction): The interaction """ queue: ResultSet = self.bot.players[inter.guild.id].queue - e: Embed = embed.queue_message(queue, title=f"Queue for {inter.guild.name}") + e: Embed = embed.queue_message(queue, self.bot, title=f"Queue for {inter.guild.name}") await inter.send(embed=e) @queue.sub_command() diff --git a/jukebot/services/music/current_song_service.py b/jukebot/services/music/current_song_service.py index 374e70e..55f9004 100644 --- a/jukebot/services/music/current_song_service.py +++ b/jukebot/services/music/current_song_service.py @@ -19,5 +19,8 @@ async def __call__(self, /, interaction: CommandInteraction): if stream and song: e = embed.music_message(song, player.loop, stream.progress) else: - e = embed.basic_message(title="Nothing is currently playing", content=f"Try `/play` to add a music !") + cmd: APISlashCommand = self.bot.get_global_command_named("play") + e = embed.basic_message( + title="Nothing is currently playing", content=f"Try to add a music !" + ) await interaction.send(embed=e) diff --git a/jukebot/services/music/resume_service.py b/jukebot/services/music/resume_service.py index 9663c2d..e688581 100644 --- a/jukebot/services/music/resume_service.py +++ b/jukebot/services/music/resume_service.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Optional -from disnake import CommandInteraction +from disnake import APISlashCommand, CommandInteraction from jukebot.abstract_components import AbstractService from jukebot.utils import embed @@ -21,9 +21,14 @@ async def __call__(self, /, interaction: CommandInteraction, silent: Optional[bo if not silent: e = embed.basic_message(title="Player resumed") await interaction.send(embed=e) - elif player.state.is_stopped and not player.queue.is_empty(): + + return + + if player.state.is_stopped and not player.queue.is_empty(): with PlayService(self.bot) as play: await play(interaction=interaction, query="") - else: - e = embed.basic_message(title="Nothing to play", content=f"Try `/play` to add a music !") - await interaction.send(embed=e) + return + + cmd: APISlashCommand = self.bot.get_global_command_named("play") + e = embed.basic_message(title="Nothing is currently playing", content=f"Try to add a music !") + await interaction.send(embed=e) diff --git a/jukebot/utils/embed.py b/jukebot/utils/embed.py index c74fd33..5d51167 100644 --- a/jukebot/utils/embed.py +++ b/jukebot/utils/embed.py @@ -5,7 +5,8 @@ from typing import TYPE_CHECKING import disnake -from disnake import Member +from disnake import APISlashCommand, Member +from disnake.ext.commands import Bot, Command from jukebot.utils import converter @@ -142,7 +143,7 @@ def basic_queue_message(title="", content=""): return embed -def queue_message(playlist: ResultSet, title=""): +def queue_message(playlist: ResultSet, bot: Bot, title=""): playlist_slice = itertools.islice(playlist, 10) content = "\n\n".join( [ @@ -155,9 +156,11 @@ def queue_message(playlist: ResultSet, title=""): total_time: int = sum([e.duration for e in playlist if not e.live]) total_time_fmt: str = converter.seconds_to_youtube_format(total_time) embed.add_field(name="Total duration", value=f"`{total_time_fmt}`") + + cmd: APISlashCommand = bot.get_global_command_named("queue") embed.add_field( name=VOID_TOKEN, - value=f"Use command `add` or `remove` to add or remove a song.", + value=f"Use command or to add or remove a song.", inline=False, ) return embed