diff options
author | Matt Kohls <mattkohls13@gmail.com> | 2018-10-29 17:11:09 -0400 |
---|---|---|
committer | Matt Kohls <mattkohls13@gmail.com> | 2018-10-29 17:11:09 -0400 |
commit | a2059e082ddfbc64cdfa7c423045e6a16bab8098 (patch) | |
tree | a65d5fb3428abb205004cd31796ca22eda7ae245 | |
parent | f78dc260bc113e458020cfacaacd26fb4c2a4a27 (diff) | |
download | SoundChan-a2059e082ddfbc64cdfa7c423045e6a16bab8098.tar.gz SoundChan-a2059e082ddfbc64cdfa7c423045e6a16bab8098.tar.bz2 SoundChan-a2059e082ddfbc64cdfa7c423045e6a16bab8098.zip |
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
-rw-r--r-- | src/main/java/soundchan/BotListener/BotListener.java | 31 | ||||
-rw-r--r-- | src/main/java/soundchan/BotListener/Commands.java | 1 |
2 files changed, 27 insertions, 5 deletions
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 } |