package com.nickolasgupton.beepsky.owner;

import com.nickolasgupton.beepsky.BotUtils;
import com.nickolasgupton.beepsky.Command;
import sx.blah.discord.handle.impl.events.guild.channel.message.MessageReceivedEvent;
import sx.blah.discord.util.EmbedBuilder;

public class OwnerCommands implements Command {

  @Override
  public boolean shouldExecute(MessageReceivedEvent event) {
    return event.getChannel().isPrivate() && event.getAuthor().getLongID() == Owner.ID;
  }

  @Override
  public void execute(MessageReceivedEvent event) {

    switch (event.getMessage().getContent().split(" ")[0].toLowerCase()) {
      case "shutdown":
        shutdown(false);
        break;
      case "restart":
      case "reboot":
        shutdown(true);
        break;
      case "ban":
        if (event.getMessage().getContent().split(" ").length == 2) {
          UserBans.ban(event.getMessage().getContent().split(" ")[1]);
        }
        break;
      case "unban":
        if (event.getMessage().getContent().split(" ").length == 2) {
          UserBans.unban(event.getMessage().getContent().split(" ")[1]);
        }
        break;
      default:
        break;
    }
  }

  @Override
  public void getCommands(MessageReceivedEvent event) {
  }

  private void shutdown(Boolean restart) {
    EmbedBuilder builder = new EmbedBuilder();
    builder.withColor(100, 255, 100);

    if (restart) {
      builder.withTitle("Restarting...");
      builder.withDescription("This may take up to a few minutes if an update is available.");
    } else {
      builder.withTitle("Shutting down...");
      builder.withDescription("Goodbye world.");
    }

    builder.withFooterText("Current version: " + BotUtils.VERSION);
    Owner.sendMessage(builder);

    System.exit(restart ? 1 : 0);
  }
}


@@ -1134,110 +1134,402 @@
     
-default:%0A        break;%0A    %7D%0A  %7D%0A%0A  @Override%0A  public void getCommands(MessageReceivedEvent event) %7B
+case %22leave%22:%0A        if (event.getMessage().getContent().split(%22 %22).length == 2) %7B%0A          leave(event.getMessage().getContent().split(%22 %22)%5B1%5D);%0A        %7D%0A        break;%0A      default:%0A        break;%0A    %7D%0A  %7D%0A%0A  @Override%0A  public void getCommands(MessageReceivedEvent event) %7B%0A  %7D%0A%0A  private void leave(String serverId) %7B%0A    BotUtils.CLIENT.getGuildByID(Long.parseLong(serverId)).leave();
 %0A  %7D

Add leave command