package com.jagrosh.jmusicbot.commands.dj;

import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.commons.utils.FinderUtil;
import com.jagrosh.jmusicbot.Bot;
import com.jagrosh.jmusicbot.audio.AudioHandler;
import com.jagrosh.jmusicbot.commands.DJCommand;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.User;

import java.util.List;


public class ForceRemoveCmd extends DJCommand
{
    public ForceRemoveCmd(Bot bot)
    {
        super(bot);
        this.name = "forceremove";
        this.help = "removes all entries by a user from the queue";
        this.arguments = "<user>";
        this.aliases = new String[]{"forcedelete", "modremove", "moddelete"};
        this.beListening = false;
        this.bePlaying = true;
    }

    @Override
    public void doCommand(CommandEvent event)
    {
        if (event.getArgs().isEmpty())
        {
            event.replyError("You need to mention a user!");
            return;
        }

        AudioHandler handler = (AudioHandler) event.getGuild().getAudioManager().getSendingHandler();
        if (handler.getQueue().isEmpty())
        {
            event.replyError("There is nothing in the queue!");
            return;
        }


        User target;
        List<Member> found = FinderUtil.findMembers(event.getArgs(), event.getGuild());

        if(found.isEmpty())
        {
            event.replyError("Unable to find the user!");
            return;
        }
        else if(found.size()>1)
        {
            event.replyWarning("Found multiple users!");
            return;
        }
        else
        {
            target = found.get(0).getUser();
        }


        int count = handler.getQueue().removeAll(target.getIdLong());
        if (count == 0)
        {
            event.replyWarning(target.getName() + " doesn't have any songs in the queue!");
        }
        else
        {
                event.replySuccess("Successfully removed `" + count + "` entries from **" + target.getName() + "**#" + target.getDiscriminator() + ".");
        }

    }
}

@@ -149,16 +149,66 @@
 erUtil;%0A
+import com.jagrosh.jdautilities.menu.OrderedMenu;%0A
 import c
@@ -233,16 +233,16 @@
 ot.Bot;%0A
-
 import c
@@ -1589,34 +1589,944 @@
         
-event.replyWarning
+OrderedMenu.Builder builder = new OrderedMenu.Builder();%0A            for(int i=0; i%3Cfound.size() && i%3C4; i++)%0A            %7B%0A                Member member = found.get(i);%0A                builder.addChoice(%22**%22+member.getUser().getName()+%22**#%22+member.getUser().getDiscriminator());%0A            %7D%0A%0A            builder.setSelection((msg, i) -%3E%0A            %7B%0A                User selectedUser = found.get(i-1).getUser();%0A                int count = handler.getQueue().removeAll(selectedUser.getIdLong());%0A                if (count == 0)%0A                %7B%0A                    event.replyWarning(%22**%22+selectedUser.getName()+%22** doesn't have any songs in the queue!%22);%0A                %7D%0A                else%0A                %7B%0A                    event.replySuccess(%22Successfully removed %60%22+count+%22%60 entries from **%22+selectedUser.getName()+%22**#%22+selectedUser.getDiscriminator()+%22.%22);%0A                %7D%0A            %7D)%0A            .setText
 (%22Found 
@@ -2539,21 +2539,311 @@
 le users
-!
+:
 %22)
+%0A            .setColor(event.getSelfMember().getColor())%0A            .useNumbers()%0A            .setUsers(event.getAuthor())%0A            .useCancelButton(true)%0A            .setCancel((msg) -%3E %7B%7D)%0A            .setEventWaiter(bot.getWaiter())%0A%0A            .build().display(event.getChannel())
 ;%0A
+%0A
         
@@ -3177,36 +3177,32 @@
   %7B%0A            
-    
 event.replySucce
@@ -3232,19 +3232,15 @@
 d %60%22
- + 
++
 count
- + 
++
 %22%60 e
@@ -3254,19 +3254,17 @@
 from **%22
- + 
++
 target.g
@@ -3275,19 +3275,15 @@
 me()
- + 
++
 %22**#%22
- + 
++
 targ
@@ -3303,19 +3303,17 @@
 inator()
- + 
++
 %22.%22);%0A  

Apply requested changes (Pass 2)