package fredboat.command.music;

import fredboat.audio.GuildPlayer;
import fredboat.audio.PlayerRegistry;
import fredboat.commandmeta.abs.Command;
import fredboat.commandmeta.abs.IMusicCommand;
import net.dv8tion.jda.MessageBuilder;
import net.dv8tion.jda.entities.Guild;
import net.dv8tion.jda.entities.Message;
import net.dv8tion.jda.entities.TextChannel;
import net.dv8tion.jda.entities.User;
import net.dv8tion.jda.player.source.AudioSource;

public class ListCommand extends Command implements IMusicCommand {

    @Override
    public void onInvoke(Guild guild, TextChannel channel, User invoker, Message message, String[] args) {
        GuildPlayer player = PlayerRegistry.get(guild.getId());
        player.currentTC = channel;
        if (player.getCurrentAudioSource() != null || !player.getAudioQueue().isEmpty()) {
            MessageBuilder mb = new MessageBuilder();
            if (player.getCurrentAudioSource() != null) {
                String status = player.isPlaying() ? "[PLAYING] " : "[PAUSED] ";
                mb.appendString(status, MessageBuilder.Formatting.BOLD)
                        .appendString(player.getCurrentAudioSource().getInfo().getTitle())
                        .appendString("\n");
            }

            //Now add the queue
            int i = 1;
            for (AudioSource src : player.getAudioQueue()) {
                mb.appendString(src.getInfo().getTitle())
                        .appendString("\n");
                if (i == 10) {
                    break;
                }
                i++;
            }

            int add = player.getCurrentAudioSource() != null ? 1 : 0;

            //Now add a timestamp for how much is remaining
            int t = player.getTotalRemainingMusicTimeSeconds();
            int sec = t % 60;
            int min = (t % 3600) / 60;
            int hrs = t / 3600;
            
            String timestamp;
            
            if (hrs != 0){
                timestamp = forceTwoDigits(hrs) +":"+ forceTwoDigits(min) +":"+ forceTwoDigits(sec);
            } else {
                timestamp = forceTwoDigits(min) +":"+ forceTwoDigits(sec);
            }

            mb.appendString("\n\nThere are a total of **")
                    .appendString(String.valueOf(player.getAudioQueue().size() + add), MessageBuilder.Formatting.BOLD)
                    .appendString("** queued songs with a remaining length of **" + timestamp + "**.");

            channel.sendMessage(mb.build());
        } else {
            channel.sendMessage("Not currently playing anything");
        }
    }

    public String forceTwoDigits(int i) {
        return i < 10 ? "0" + i : Integer.toString(i);
    }

}

@@ -26,16 +26,74 @@
 music;%0A%0A
+import com.sedmelluq.discord.lavaplayer.track.AudioTrack;%0A
 import f
@@ -450,58 +450,8 @@
 ser;
-%0Aimport net.dv8tion.jda.player.source.AudioSource;
 %0A%0Apu
@@ -764,73 +764,30 @@
 .get
-CurrentAudioSource() != null %7C%7C !player.getAudioQueue().isEmpty()
+PlayingTrack() != null
 ) %7B%0A
@@ -857,53 +857,116 @@
    i
-f (player.getCurrentAudioSource() != null) %7B%0A
+nt i = 1;%0A            for (AudioTrack at : player.getRemainingTracks()) %7B%0A                if (i == 0) %7B%0A    
     
@@ -1050,32 +1050,36 @@
                 
+    
 mb.appendString(
@@ -1134,32 +1134,36 @@
                 
+  
+  
 .appendString(pl
@@ -1164,61 +1164,30 @@
 ing(
-player.getCurrentAudioSource().getInfo().getTitle())%0A
+at.getInfo().title)%0A  
     
@@ -1198,32 +1198,34 @@
                 
+  
 .appendString(%22%5C
@@ -1245,127 +1245,25 @@
     
-%7D%0A%0A
     
-        //Now add the queue%0A            int i = 1;%0A            for (AudioSource src : player.getAudioQueue()) %7B%0A
+%7D else %7B%0A    
     
@@ -1294,11 +1294,10 @@
 ing(
-src
+at
 .get
@@ -1307,20 +1307,19 @@
 o().
-getTitle())%0A
+title)%0A    
     
@@ -1367,32 +1367,36 @@
                 
+  
+  
 if (i == 10) %7B%0A 
@@ -1390,24 +1390,28 @@
 (i == 10) %7B%0A
+    
             
@@ -1437,24 +1437,28 @@
             
+    
 %7D%0A          
@@ -1467,12 +1467,9 @@
     
-i++;
+%7D
 %0A   
@@ -1469,39 +1469,32 @@
   %7D%0A        
-    %7D%0A%0A
         
     int add 
@@ -1485,69 +1485,26 @@
     
-    int add = player.getCurrentAudioSource() != null ? 1 : 0;
+i++;%0A            %7D
 %0A%0A  
@@ -1726,28 +1726,16 @@
 / 3600;%0A
-            
 %0A       
@@ -1757,28 +1757,16 @@
 estamp;%0A
-            
 %0A       
@@ -1783,16 +1783,17 @@
 rs != 0)
+ 
 %7B%0A      
@@ -1835,19 +1835,21 @@
 s(hrs) +
+ 
 %22:%22
+ 
 + forceT
@@ -1855,35 +1855,37 @@
 TwoDigits(min) +
+ 
 %22:%22
+ 
 + forceTwoDigits
@@ -1961,19 +1961,21 @@
 s(min) +
+ 
 %22:%22
+ 
 + forceT
@@ -2126,18 +2126,23 @@
 .get
-AudioQueue
+RemainingTracks
 ().s
@@ -2150,14 +2150,8 @@
 ze()
- + add
 ), M

Fix ;;list