package com.blamejared.mcbot.commands;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.blamejared.mcbot.commands.api.Command;
import com.blamejared.mcbot.commands.api.CommandContext;
import com.blamejared.mcbot.commands.api.CommandException;
import com.blamejared.mcbot.commands.api.CommandPersisted;
import com.blamejared.mcbot.commands.api.Flag;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.gson.reflect.TypeToken;

@Command
public class CommandSlap extends CommandPersisted<List<String>> {
    
    private static final Flag FLAG_ADD = new SimpleFlag("add", false);
    private static final Flag FLAG_LS = new SimpleFlag("ls", false);

	private List<String> options = Lists.newArrayList();
    private Random rand = new Random();

    public CommandSlap() {
        super("slap", false, Lists.newArrayList(FLAG_ADD, FLAG_LS), ArrayList::new);
        options.add("with a large trout!");
        options.add("with a big bat!");
        options.add("with a frying pan!");
        options.add("like a little bitch!");
    }
    
    @Override
    public TypeToken<List<String>> getDataType() {
        return new TypeToken<List<String>>(){};
    }
    
    @Override
    public void process(CommandContext ctx) throws CommandException {
        if(ctx.argCount() < 1) {
            throw new CommandException("Not enough arguments.");
        }
        
        if (ctx.hasFlag(FLAG_ADD)) {
        	storage.get(ctx.getMessage().getGuild()).add(Joiner.on(' ').join(ctx.getArgs()));
        	ctx.getMessage().getChannel().sendMessage("Added new slap suffix.");
        	return;
        } 
        if (ctx.hasFlag(FLAG_LS)) {
        }
        StringBuilder builder = new StringBuilder(ctx.getMessage().getAuthor().getName());
        List<String> suffixes = Lists.newArrayList(options);
        suffixes.addAll(storage.get(ctx.getMessage().getGuild()));
        
        builder.append(" slapped ").append(Joiner.on(' ').join(ctx.getArgs())).append(" " + suffixes.get(rand.nextInt(suffixes.size())));
        ctx.getMessage().getChannel().sendMessage(escapeMentions(ctx.getMessage().getGuild(), builder.toString()));
    }
    
    public String getUsage() {
        return "<user>";
    }
}

@@ -1322,16 +1322,465 @@
 ption %7B%0A
+        if (ctx.hasFlag(FLAG_LS)) %7B%0A            StringBuilder builder = new StringBuilder();%0A            builder.append(%22List of custom slap suffixes:%5Cn%22);%0A            int i = 0;%0A            for (String suffix : storage.get(ctx.getMessage())) %7B%0A                builder.append(i).append(%22) %22).append(suffix).append(%22%5Cn%22);%0A            %7D%0A            ctx.getMessage().getChannel().sendMessage(builder.toString());%0A            return;%0A        %7D%0A        %0A
         
@@ -1870,33 +1870,32 @@
 ts.%22);%0A        %7D
-%0A
         %0A       
@@ -2125,53 +2125,8 @@
  %7D %0A
-        if (ctx.hasFlag(FLAG_LS)) %7B%0A        %7D
 %0A   

Fix slap -ls