package com.robothand.highqualitybot.command;

import com.robothand.highqualitybot.Config;
import com.robothand.highqualitybot.music.GuildMusicPlayer;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.MessageChannel;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;

/**
 * SkipCommand.java
 * Skips the currently playing song. Stops playback if there is nothing left in the queue.
 */
public class SkipCommand extends Command {
    @Override
    public String[] getNames() {
        return new String[] {"skip", "next"};
    }

    @Override
    public String getDescription() {
        return "Skips to the next song in the queue. If there are no other songs, simply stops playback.\n" +
                "Usage: " + Config.PREFIX + "skip";
    }

    @Override
    public String getShortDesc() {
        return "Skips the currently playing song.";
    }

    @Override
    public void execute(MessageReceivedEvent event, String[] args) {
        GuildMusicPlayer musicPlayer;
        Guild guild = event.getGuild();
        MessageChannel channel = event.getChannel();

        musicPlayer = GuildMusicPlayer.getPlayer(guild);

        if (musicPlayer.getPlayingTrack() == null) {
            log.debug("{}: No currently playing track, doing nothing", guild.getName());
            channel.sendMessage("There isn't anything playing to skip!").queue();
        } else {
            musicPlayer.skipTrack();
            channel.sendMessage("Skipping to next track...").queue();
        }
    }
}

@@ -1411,16 +1411,226 @@
  else %7B%0A
+            StringBuilder message = new StringBuilder();%0A%0A            // skip the track%0A            message.append(%22Skipping to next track...%22);%0A            log.debug(%22%7B%7D: Skipping track...%22, guild.getName());%0A
         
@@ -1654,24 +1654,25 @@
 kipTrack();%0A
+%0A
             
@@ -1675,55 +1675,375 @@
     
-channel.sendMessage(%22Skipping to next track...%22
+// output next track's name, if applicable%0A            if (musicPlayer.getPlayingTrack() == null) %7B%0A                message.append(%22%5CnReached end of playlist!%22);%0A            %7D else %7B%0A                message.append(%22%5Cn**%22).append(musicPlayer.getPlayingTrack().getInfo().title).append(%22** is up next!%22);%0A            %7D%0A%0A            channel.sendMessage(message.toString()
 ).qu

add some informative output to the skip command