From a2059e082ddfbc64cdfa7c423045e6a16bab8098 Mon Sep 17 00:00:00 2001 From: Matt Kohls Date: Mon, 29 Oct 2018 17:11:09 -0400 Subject: Adding status message Providing a way to get more information about the currently playing track as well as a way to get the current audio volume --- .../java/soundchan/BotListener/BotListener.java | 31 ++++++++++++++++++---- src/main/java/soundchan/BotListener/Commands.java | 1 + 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/java/soundchan/BotListener/BotListener.java b/src/main/java/soundchan/BotListener/BotListener.java index 9bcccfe..e724f38 100644 --- a/src/main/java/soundchan/BotListener/BotListener.java +++ b/src/main/java/soundchan/BotListener/BotListener.java @@ -208,9 +208,12 @@ public class BotListener extends ListenerAdapter{ // Unpause the song/sound in the queue unpauseTrack(channel); - }else if(enumCommand == Commands.playingnow){ + }else if(enumCommand == Commands.playingnow) { // Print the currently playing song - printCurrentlyPlaying(channel); + printCurrentlyPlaying(channel, false); + } else if(enumCommand == Commands.status) { + // Print currently playing song with extra info + printCurrentlyPlaying(channel, true); }else if(enumCommand == Commands.summon){ connectToUserVoiceChannel(monitoredGuild.getAudioManager(), event.getMember().getEffectiveName()); }else if(enumCommand == Commands.help){ @@ -253,11 +256,29 @@ public class BotListener extends ListenerAdapter{ channel.sendMessage("Unpaused playback.").queue(); } - private void printCurrentlyPlaying(final MessageChannel channel){ + /** + * Prints out information about what is currently playing and possibly information about the track and/or the audio volume + * @param channel The channel to respond on + * @param printStatus Print out extra information such as track information and/or audio volume + */ + private void printCurrentlyPlaying(final MessageChannel channel, boolean printStatus){ GuildMusicManager musicManager = getGuildAudioPlayer(); AudioTrack currentlyPlaying = musicManager.player.getPlayingTrack(); - channel.sendMessage("Currently Playing: " + currentlyPlaying.getInfo().title + " by " + currentlyPlaying.getInfo().author).queue(); - + String message = ""; + if(currentlyPlaying != null) { + message = "Currently Playing: " + currentlyPlaying.getInfo().title + " by " + currentlyPlaying.getInfo().author; + if(printStatus) { + message += ( "\nTime : " + musicManager.player.getPlayingTrack().getPosition() + " | " + musicManager.player.getPlayingTrack().getDuration() + + "\nPaused = " + musicManager.player.isPaused() + + "\nVolume = " + musicManager.player.getVolume() + "%"); + } + } else { + message = "Nothing currently playing"; + if(printStatus) { + message += ("\nVolume = " + musicManager.player.getVolume() + "%"); + } + } + channel.sendMessage(message).queue(); } private void loadAndPlay(final MessageChannel channel, final String trackUrl, boolean preempt) { diff --git a/src/main/java/soundchan/BotListener/Commands.java b/src/main/java/soundchan/BotListener/Commands.java index e054de1..046bcab 100644 --- a/src/main/java/soundchan/BotListener/Commands.java +++ b/src/main/java/soundchan/BotListener/Commands.java @@ -11,6 +11,7 @@ public enum Commands { skip, list, playingnow, + status, summon, help } -- cgit v1.2.3