From 6d8c86d7683e18cdc62370c479a9db24cc8b100c Mon Sep 17 00:00:00 2001 From: Brandon Date: Sat, 7 Apr 2018 19:18:18 -0400 Subject: Add list queued support --- src/main/java/soundchan/Main.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/main/java/soundchan/Main.java') diff --git a/src/main/java/soundchan/Main.java b/src/main/java/soundchan/Main.java index 326285f..8b1ccfc 100644 --- a/src/main/java/soundchan/Main.java +++ b/src/main/java/soundchan/Main.java @@ -131,7 +131,11 @@ public class Main extends ListenerAdapter { pauseTrack(channel); } else if ("~unpause".equals(command[0])) { unpauseTrack(channel); - }} + } else if ("~list".equals(command[0])) { + listTracks(channel); + } + + } super.onMessageReceived(event); } @@ -142,6 +146,17 @@ public class Main extends ListenerAdapter { channel.sendMessage("Volume now set to " + volume + "%").queue(); } + private void listTracks(final MessageChannel channel) { + GuildMusicManager musicManager = getGuildAudioPlayer(); + List queueContents = musicManager.scheduler.getQueueContents(); + String printMessage = "Tracks in the queue:\n"; + for (String track: + queueContents) { + printMessage = printMessage + track + "\n"; + } + channel.sendMessage(printMessage).queue(); + } + private void pauseTrack(final MessageChannel channel){ GuildMusicManager musicManager = getGuildAudioPlayer(); musicManager.player.setPaused(true); @@ -163,6 +178,7 @@ public class Main extends ListenerAdapter { int timeStart = trackUrl.lastIndexOf('='); if(timeStart != -1){ String timeString = trackUrl.substring(timeStart); + //The format will be 1h2m53s, need to parse that into seconds and then call //track.setPosition(long position) -- cgit v1.2.3