Skip to content

Commit

Permalink
feat: add interactive command text to embed
Browse files Browse the repository at this point in the history
  • Loading branch information
Dysta committed Sep 19, 2024
1 parent 9c262b0 commit 3c3256a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion jukebot/cogs/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion jukebot/services/music/current_song_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 </play:{cmd.id}> to add a music !"
)
await interaction.send(embed=e)
15 changes: 10 additions & 5 deletions jukebot/services/music/resume_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 </play:{cmd.id}> to add a music !")
await interaction.send(embed=e)
9 changes: 6 additions & 3 deletions jukebot/utils/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
[
Expand All @@ -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 </queue add:{cmd.id}> or </queue remove:{cmd.id}> to add or remove a song.",
inline=False,
)
return embed
Expand Down

0 comments on commit 3c3256a

Please sign in to comment.