package stream.flarebot.flarebot.commands.moderation;

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.commands.Command;
import stream.flarebot.flarebot.commands.CommandType;
import stream.flarebot.flarebot.objects.GuildWrapper;
import stream.flarebot.flarebot.objects.RestActionWrapper;
import stream.flarebot.flarebot.util.ConfirmUtil;
import stream.flarebot.flarebot.util.GeneralUtils;
import stream.flarebot.flarebot.util.MessageUtils;

import java.awt.Color;

public class PruneCommand implements Command {

    @Override
    public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
        if (args.length != 0) {
            if (args[0].equalsIgnoreCase("server") && args.length == 2) {
                if (getPermissions(channel).hasPermission(member, "flarebot.prune.server")) {
                    int amount;
                    try {
                        amount = Integer.parseInt(args[1]);
                    } catch (NumberFormatException e) {
                        MessageUtils.sendErrorMessage("Please enter a valid amount of days!", channel);
                        return;
                    }

                    if (amount == 0) {
                        MessageUtils.sendErrorMessage("The amount of days has to be more that 0!", channel);
                        return;
                    }

                    int userSize = guild.getGuild().getPrunableMemberCount(amount).complete();
                    channel.sendMessage(MessageUtils.getEmbed(sender)
                            .setColor(Color.RED)
                            .setDescription(GeneralUtils.formatCommandPrefix(channel, "Are you sure you want to prune " + userSize + " members?\n" +
                                    "To confirm type `{%}prune confirm` within 1 minute!"))
                            .build()).queue();

                    ConfirmUtil.pushAction(sender.getId(),
                            new RestActionWrapper(guild.getGuild().getController()
                                    .prune(amount)
                                    .reason("Pruned by user: " + MessageUtils.getTag(sender)), this.getClass()));
                    return;

                } else {
                    MessageUtils.sendErrorMessage("You need the permission `flarebot.prune.server` to do this!", channel);
                    return;
                }
            } else if (args[0].equalsIgnoreCase("confirm")) {
                if (ConfirmUtil.checkExists(sender.getId(), this.getClass())) {
                    ConfirmUtil.get(sender.getId(), this.getClass()).queue();
                    ConfirmUtil.remove(sender.getId(), this.getClass());
                } else {
                    MessageUtils.sendErrorMessage("You haven't got any action to confirm!", channel);
                }
                return;
            }
        }
        MessageUtils.getUsage(this, channel, sender).queue();
    }

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

    @Override
    public String getDescription() {
        return "Allows server mods to easily prune members from a discord";
    }

    @Override
    public String getUsage() {
        return "`{%}prune server <days>` - Prunes the entire server." +
                " Only members inactive longer than the specified amount of days will be removed\n" +
                "`{%}prune confirm` - Confirms a user's actions";
    }

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

@@ -943,90 +943,53 @@
     
-if (getPermissions(channel).hasPermission(member, %22flarebot.prune.server%22)) %7B%0A    
+// Re-add sub-permission when roles is added%0A
     
@@ -1028,20 +1028,16 @@
         
-    
 try %7B%0A  
@@ -1054,20 +1054,16 @@
         
-  
-  
 amount =
@@ -1090,20 +1090,16 @@
 gs%5B1%5D);%0A
-    
         
@@ -1138,28 +1138,24 @@
 eption e) %7B%0A
-    
             
@@ -1258,36 +1258,32 @@
             
-  
-  
 return;%0A
             
@@ -1262,36 +1262,32 @@
         return;%0A
-    
                 
@@ -1301,28 +1301,24 @@
             
-    
 if (amount =
@@ -1336,36 +1336,32 @@
                 
- 
-   
 MessageUtils.sen
@@ -1441,36 +1441,32 @@
                 
-    
 return;%0A        
@@ -1465,36 +1465,32 @@
                 
-    
 %7D%0A%0A             
@@ -1488,28 +1488,24 @@
             
- 
-   
 int userSize
@@ -1583,20 +1583,16 @@
         
-    
 channel.
@@ -1633,20 +1633,16 @@
 sender)%0A
-    
         
@@ -1698,28 +1698,24 @@
             
-    
 .setDescript
@@ -1855,20 +1855,16 @@
         
-    
 %22To conf
@@ -1911,20 +1911,16 @@
 ute!%22))%0A
-    
         
@@ -1963,36 +1963,32 @@
                 
-    
 ConfirmUtil.push
@@ -2010,20 +2010,16 @@
 etId(),%0A
-    
         
@@ -2121,20 +2121,16 @@
         
-   
- 
 .prune(a
@@ -2136,20 +2136,16 @@
 amount)%0A
-    
         
@@ -2266,214 +2266,15 @@
     
-    
 return;
-%0A%0A                %7D else %7B%0A                    MessageUtils.sendErrorMessage(%22You need the permission %60flarebot.prune.server%60 to do this!%22, channel);%0A                    return;%0A                %7D
 %0A   

Remove sub-perm for now