package stream.flarebot.flarebot.commands.general;

import net.dv8tion.jda.core.JDA;
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 org.apache.commons.lang3.text.WordUtils;
import stream.flarebot.flarebot.FlareBot;
import stream.flarebot.flarebot.commands.Command;
import stream.flarebot.flarebot.commands.CommandType;
import stream.flarebot.flarebot.objects.GuildWrapper;
import stream.flarebot.flarebot.util.GeneralUtils;
import stream.flarebot.flarebot.util.MessageUtils;

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

public class ShardInfoCommand implements Command {

    @Override
    public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
        List<String> headers = new ArrayList<>();
        headers.add("Shard ID");
        headers.add("Status");
        headers.add("Guild Count");
        headers.add("Ping");
        headers.add("VCs");

        List<List<String>> table = new ArrayList<>();
        for (JDA jda : FlareBot.getInstance().getClients()) {
            List<String> row = new ArrayList<>();
            row.add(GeneralUtils.getShardId(jda) + (GeneralUtils.getShardIdAsInt(channel.getJDA()) == GeneralUtils.getShardIdAsInt(jda) ? " (You)" : ""));
            row.add(WordUtils.capitalizeFully(jda.getStatus().toString().replace("_", " ")));
            row.add(String.valueOf(jda.getGuilds().size()));
            row.add(String.valueOf(jda.getPing()));
            row.add(String.valueOf(jda.getVoiceChannels().stream().filter(vc -> vc.getMembers().contains(vc.getGuild().getSelfMember())).count()));
            table.add(row);
        }

        channel.sendMessage(MessageUtils.makeAsciiTable(headers, table, null, "swift")).queue();
    }

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

    @Override
    public String getDescription() {
        return "Shows info about a shard";
    }

    @Override
    public String getUsage() {
        return "{%}shardsinfo";
    }

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

@@ -999,19 +999,12 @@
 dd(%22
-Guild Count
+Ping
 %22);%0A
@@ -1016,36 +1016,43 @@
    headers.add(%22
-Ping
+Guild Count
 %22);%0A        head
@@ -1529,21 +1529,12 @@
 .get
-Guilds().size
+Ping
 ()))
@@ -1569,36 +1569,45 @@
 .valueOf(jda.get
-Ping
+Guilds().size
 ()));%0A          

Change order