package com.tisawesomeness.minecord.command.admin;

import com.tisawesomeness.minecord.command.Command;
import com.tisawesomeness.minecord.command.CommandContext;
import com.tisawesomeness.minecord.database.Database;
import com.tisawesomeness.minecord.debug.DebugOption;
import com.tisawesomeness.minecord.debug.GuildCacheDebugOption;
import com.tisawesomeness.minecord.debug.JDADebugOption;
import com.tisawesomeness.minecord.debug.UserCacheDebugOption;

import net.dv8tion.jda.api.sharding.ShardManager;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class DebugCommand extends Command {
    public CommandInfo getInfo() {
        return new CommandInfo(
            "debug",
            "Prints out debug info.",
            "[option]",
            new String[]{"dump"},
            0,
            true,
            true,
            false
        );
    }

    private final List<DebugOption> debugOptions;
    public DebugCommand(ShardManager sm, Database db) {
        debugOptions = Arrays.asList(
                new JDADebugOption(sm),
                new GuildCacheDebugOption(db),
                new UserCacheDebugOption(db)
        );
    }

    public Result run(CommandContext txt) {
        if (!txt.config.debugMode) {
            return new Result(Outcome.WARNING, "The bot is not in debug mode.");
        }

        if (txt.args.length == 0) {
            String possibleOptions = debugOptions.stream()
                    .map(d -> String.format("`%s`", d.getName()))
                    .collect(Collectors.joining(", "));
            return new Result(Outcome.SUCCESS, "Possible options: " + possibleOptions);
        }

        for (DebugOption d : debugOptions) {
            if (d.getName().equalsIgnoreCase(txt.args[0])) {
                String debugInfo = d.debug();
                System.out.println(debugInfo); // Useful to have in console
                return new Result(Outcome.SUCCESS, debugInfo);
            }
        }
        return new Result(Outcome.WARNING, ":warning: Not a valid debug option.");
    }
}

@@ -430,30 +430,132 @@
 bug.
-UserCacheDebugOption;%0A
+ThreadDebugOption;%0Aimport com.tisawesomeness.minecord.debug.UserCacheDebugOption;%0A%0Aimport net.dv8tion.jda.api.entities.User;
 %0Aimp
@@ -1186,16 +1186,57 @@
 on(sm),%0A
+                new ThreadDebugOption(),%0A
         
@@ -1998,27 +1998,210 @@
     
-System.out.println(
+User author = txt.e.getAuthor();%0A                String requestedBy = String.format(%22Requested By %25s (%25s)%5Cn%22, author.getAsTag(), author.getId());%0A                System.out.println(%22%5Cn%22 + requestedBy + 
 debu
@@ -2205,16 +2205,23 @@
 ebugInfo
+ + %22%5Cn%22
 ); // Us

Format &debug console message