package stream.flarebot.flarebot.commands.music;

import com.arsenarsen.lavaplayerbridge.PlayerManager;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.User;
import stream.flarebot.flarebot.FlareBot;
import stream.flarebot.flarebot.MessageUtils;
import stream.flarebot.flarebot.commands.Command;
import stream.flarebot.flarebot.commands.CommandType;

import java.awt.*;

public class SearchCommand implements Command {

    private FlareBot bot;

    public SearchCommand(FlareBot bot) {
        this.bot = bot;
    }

    @Override
    public void onCommand(User sender, TextChannel channel, Message message, String[] args, Member member) {
        channel.sendMessage(new EmbedBuilder().setColor(Color.YELLOW).setDescription("This is deprecated! Please use _play instead!").build());
        new PlayCommand(bot).onCommand(sender, channel, message, args, member);
    }

    @Override
    public String getCommand() {
        return "search";
    }

    @Override
    public String getDescription() {
        return "Search for a song on YouTube. Usage: `search URL` or `search WORDS`";
    }

    @Override
    public String getUsage() {
        return "{%}search <URL/words>";
    }

    @Override
    public CommandType getType() {
        return CommandType.MUSIC;
    }

}

@@ -514,16 +514,67 @@
 andType;
+%0Aimport stream.flarebot.flarebot.music.VideoThread;
 %0A%0Aimport
@@ -648,28 +648,42 @@
 private 
-FlareBot bot
+PlayerManager musicManager
 ;%0A%0A    p
@@ -735,17 +735,44 @@
 his.
-bot = bot
+musicManager = bot.getMusicManager()
 ;%0A  
@@ -1055,79 +1055,979 @@
     
-new PlayCommand(bot).onCommand(sender, channel, message, args, member);
+if (args.length %3E 0) %7B%0A            if (args%5B0%5D.startsWith(%22http%22) %7C%7C args%5B0%5D.startsWith(%22www.%22)) %7B%0A                VideoThread.getThread(args%5B0%5D, channel, sender).start();%0A            %7D else %7B%0A                String term = %22%22;%0A                for (String s : args) %7B%0A                    term += s + %22 %22;%0A                %7D%0A                term = term.trim();%0A                VideoThread.getSearchThread(term, channel, sender).start();%0A            %7D%0A        %7D else %7B%0A            boolean playing = musicManager.getPlayer(channel.getGuild().getId()).getPlayingTrack() != null;%0A            boolean paused = musicManager.getPlayer(channel.getGuild().getId()).getPaused();%0A            if (!playing && !paused) %7B%0A                MessageUtils.sendErrorMessage(%22There is no music playing!%22, channel);%0A            %7D else %7B%0A                musicManager.getPlayer(channel.getGuild().getId()).play();%0A                channel.sendMessage(%22Resuming...!%22).queue();%0A            %7D%0A        %7D
 %0A   

Make arsen happy again