/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Command.InformationModule;

import Command.*;
import static Command.InformationModule.InfoBotCommand.HELP;
import Config.Info;
import Main.Main;
import java.awt.Color;
import java.time.Instant;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.MessageEmbed;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;

/**
 *
 * @author Alien Ideology <alien.ideology at alien.org>
 */
public class StatusCommand implements Command{

    private EmbedBuilder embedstatus = new EmbedBuilder();
    private String type = "";
    
    public StatusCommand(String invoke)
    {
        if("status".equals(invoke)) type = "status";
        else if("uptime".equals(invoke)) type = "uptime";
    }
    
    @Override
    public boolean called(String[] args, MessageReceivedEvent e) {
        return true;
    }

    @Override
    public void help(MessageReceivedEvent e) {
        embed.setColor(Color.red);
        embed.setTitle("Information Module", null);
        embed.addField("BotInfo -Help", HELP, true);
        embed.setFooter("Command Help/Usage", Info.I_help);
        embed.setTimestamp(Instant.now());

        MessageEmbed me = embed.build();
        e.getChannel().sendMessage(me).queue();
        embed.clearFields();
    }

    @Override
    public void action(String[] args, MessageReceivedEvent e) {
        
        JDA bot = e.getJDA();
        String avatar, status, game, shard, upinfo;
        int guild;
        long timeCurrent = System.currentTimeMillis(), uptime;

        avatar = bot.getSelfUser().getAvatarUrl();
        status = bot.getPresence().getStatus().getKey();
        guild = bot.getGuilds().size();
        try{shard = bot.getShardInfo().getShardString();} catch(NullPointerException ne) {shard = "None";}
        uptime = timeCurrent - Main.timeStart;
        upinfo = uptime/3600000 + " hours, " + (uptime/60000)%60 + " minutes, and " + (uptime/1000)%60 + " seconds.";
        
        if(args.length == 0)
        {
            if("uptime".equals(type))
            {
                e.getTextChannel().sendMessage("AIBot has been up for: " + upinfo).queue();
            }
            
            else if("status".equals(type))
            {
                embedstatus.setColor(Color.blue);
                embedstatus.setTitle("AIBot Status", null);
                embedstatus.setThumbnail(avatar);
                
                embedstatus.addField("Uptime", upinfo, true);
                embedstatus.addField("Status", status, true);
                embedstatus.addField("Servers", String.valueOf(guild), true);
                embedstatus.addField("Shards", shard, true);
                embedstatus.setFooter("Requested by " + e.getAuthor().getName(), e.getAuthor().getEffectiveAvatarUrl());
                embedstatus.setTimestamp(Instant.now());

                MessageEmbed me = embedstatus.build();
                e.getChannel().sendMessage(me).queue();
                embedstatus.clearFields();   
            }
        }
    }

    @Override
    public void executed(boolean success, MessageReceivedEvent e) {
        
    }
    
}

@@ -313,16 +313,38 @@
 g.Info;%0A
+import Config.Prefix;%0A
 import M
@@ -353,16 +353,16 @@
 n.Main;%0A
-
 import j
@@ -709,16 +709,306 @@
 mmand%7B%0A%0A
+    public final static String HELP = %22This command is for getting this bot's status.%5Cn%22%0A                              + %22Command Usage: %60%22 + Prefix.getDefaultPrefix() + %22status%60 or %60%22 + Prefix.getDefaultPrefix() + %22uptime%60%5Cn%22%0A                              + %22Parameter: %60-h %7C null%60%22;%0A    %0A
     priv
@@ -1546,15 +1546,14 @@
 ld(%22
-BotInfo
+Status
  -He
@@ -2511,32 +2511,32 @@
 == 0)%0A        %7B%0A
-
             if(%22
@@ -2527,24 +2527,159 @@
             
+if(args.length %3E 0 && %22-h%22.equals(args%5B1%5D))%0A            %7B%0A                help(e);%0A            %7D%0A                    %0A            else 
 if(%22uptime%22.

Add Status/UptimeCommand help message.