diff --git a/src/main/kotlin/io/ileukocyte/hibernum/commands/music/NowPlayingCommand.kt b/src/main/kotlin/io/ileukocyte/hibernum/commands/music/NowPlayingCommand.kt index 60e637e..efa2f78 100644 --- a/src/main/kotlin/io/ileukocyte/hibernum/commands/music/NowPlayingCommand.kt +++ b/src/main/kotlin/io/ileukocyte/hibernum/commands/music/NowPlayingCommand.kt @@ -33,8 +33,8 @@ class NowPlayingCommand : TextCommand { override val name = "nowplaying" override val description = "Shows information about the track that is currently playing" override val options = setOf( - OptionData(OptionType.BOOLEAN, "gui", "Whether any graphic buttons should " + - "be added to the player (default is true)")) + OptionData(OptionType.BOOLEAN, "gui-player", "Whether the button player should " + + "be added to the bot message (default is true)")) override val aliases = setOf("np", "now", "playing", "playing-now") override val staleInteractionHandling = StaleInteractionHandling.REMOVE_COMPONENTS @@ -44,23 +44,25 @@ class NowPlayingCommand : TextCommand { ?: throw CommandException("No track is currently playing!") val buttons = mutableSetOf( - Button.primary("$name-${event.author.idLong}-update", "Update"), Button.secondary( - "$name-${event.author.idLong}-playpause", + "$name-${event.author.idLong}-true-playpause", "Pause".applyIf(audioPlayer.player.isPaused) { "Play" }, ), - Button.secondary("$name-${event.author.idLong}-stop", "Stop"), - audioPlayer.scheduler.loopMode.getButton(name, event.author.id), + Button.secondary("$name-${event.author.idLong}-true-stop", "Stop"), + audioPlayer.scheduler.loopMode.getButton(name, "${event.author.id}-true"), ) if (audioPlayer.scheduler.queue.isNotEmpty()) { - buttons += Button.secondary("$name-${event.author.idLong}-skip", "Skip") + buttons += Button.secondary("$name-${event.author.idLong}-true-skip", "Skip") } event.channel.sendMessageEmbeds(playingEmbed(event.jda, audioPlayer, track)) .setComponents( ActionRow.of(buttons), - ActionRow.of(Button.danger("$name-${event.author.idLong}-exit", "Close")), + ActionRow.of( + Button.primary("$name-${event.author.idLong}-true-update", "Update"), + Button.danger("$name-${event.author.idLong}-true-exit", "Close"), + ), ).queue() } @@ -69,29 +71,34 @@ class NowPlayingCommand : TextCommand { val track = audioPlayer.player.playingTrack ?: throw CommandException("No track is currently playing!") - val gui = event.getOption("gui")?.asBoolean ?: true + val addGui = event.getOption("gui-player")?.asBoolean ?: true - val buttons = mutableSetOf( - Button.primary("$name-${event.user.idLong}-update", "Update"), - Button.secondary( - "$name-${event.user.idLong}-playpause", - "Pause".applyIf(audioPlayer.player.isPaused) { "Play" }, - ), - Button.secondary("$name-${event.user.idLong}-stop", "Stop"), - audioPlayer.scheduler.loopMode.getButton(name, event.user.id), - ) + val actionRows = mutableSetOf() - if (audioPlayer.scheduler.queue.isNotEmpty()) { - buttons += Button.secondary("$name-${event.user.idLong}-skip", "Skip") + if (addGui) { + val buttons = mutableSetOf( + Button.secondary( + "$name-${event.user.idLong}-true-playpause", + "Pause".applyIf(audioPlayer.player.isPaused) { "Play" }, + ), + Button.secondary("$name-${event.user.idLong}-true-stop", "Stop"), + audioPlayer.scheduler.loopMode.getButton(name, "${event.user.id}-true"), + ) + + if (audioPlayer.scheduler.queue.isNotEmpty()) { + buttons += Button.secondary("$name-${event.user.idLong}-true-skip", "Skip") + } + + actionRows += ActionRow.of(buttons) } - val actionRows = setOf( - ActionRow.of(buttons), - ActionRow.of(Button.danger("$name-${event.user.idLong}-exit", "Close")), + actionRows += ActionRow.of( + Button.primary("$name-${event.user.idLong}-$addGui-update", "Update"), + Button.danger("$name-${event.user.idLong}-exit", "Close"), ) event.replyEmbeds(playingEmbed(event.jda, audioPlayer, track)) - .applyIf(gui) { setComponents(actionRows) } + .setComponents(actionRows) .queue() } @@ -107,24 +114,31 @@ class NowPlayingCommand : TextCommand { return } + val addGui = id[1].toBooleanStrict() + fun updatePlayer() { - val buttons = mutableSetOf( - Button.primary("$name-${event.user.idLong}-update", "Update"), - Button.secondary( - "$name-${event.user.idLong}-playpause", - "Pause".applyIf(audioPlayer.player.isPaused) { "Play" }, - ), - Button.secondary("$name-${event.user.idLong}-stop", "Stop"), - audioPlayer.scheduler.loopMode.getButton(name, event.user.id), - ) + val actionRows = mutableSetOf() + + if (addGui) { + val buttons = mutableSetOf( + Button.secondary( + "$name-${event.user.idLong}-true-playpause", + "Pause".applyIf(audioPlayer.player.isPaused) { "Play" }, + ), + Button.secondary("$name-${event.user.idLong}-true-stop", "Stop"), + audioPlayer.scheduler.loopMode.getButton(name, "${event.user.id}-true"), + ) + + if (audioPlayer.scheduler.queue.isNotEmpty()) { + buttons += Button.secondary("$name-${event.user.idLong}-true-skip", "Skip") + } - if (audioPlayer.scheduler.queue.isNotEmpty()) { - buttons += Button.secondary("$name-${event.user.idLong}-skip", "Skip") + actionRows += ActionRow.of(buttons) } - val actionRows = setOf( - ActionRow.of(buttons), - ActionRow.of(Button.danger("$name-${event.user.idLong}-exit", "Close")), + actionRows += ActionRow.of( + Button.primary("$name-${event.user.idLong}-$addGui-update", "Update"), + Button.danger("$name-${event.user.idLong}-exit", "Close"), ) event.editMessageEmbeds(playingEmbed(event.jda, audioPlayer, audioPlayer.player.playingTrack))