package com.nincraft.ninbot.util;

import com.nincraft.ninbot.command.*;
import lombok.Getter;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;

public class CommandParser {

    @Getter
    private static final CommandParser instance = new CommandParser();
    @Getter
    private HashMap<String, AbstractCommand> commandHashMap;

    public CommandParser() {
        commandHashMap = new HashMap<>();
        commandHashMap.put("subscribe", new SubscribeCommand());
        commandHashMap.put("unsubscribe", new UnsubscribeCommand());
        commandHashMap.put("list", new ListCommand());
        commandHashMap.put("help", new HelpCommand());
        commandHashMap.put("events", new EventCommand());
    }

    public void parseEvent(MessageReceivedEvent event) {
        String message = event.getMessage().getContent();
        if (StringUtils.isNotBlank(message)) {
            AbstractCommand command = commandHashMap.get(getCommand(message));
            if (command != null) {
                command.execute(event);
            }
        }
    }

    private String getCommand(String message) {
        String[] splitMessage = message.split(" ");
        if (splitMessage.length > 1) {
            return splitMessage[1] != null ? splitMessage[1].toLowerCase() : StringUtils.EMPTY;
        }
        return null;
    }
}

@@ -59,39 +59,127 @@
 bot.
-command.*;%0Aimport lombok.Getter
+Ninbot;%0Aimport com.nincraft.ninbot.command.*;%0Aimport lombok.Getter;%0Aimport net.dv8tion.jda.core.entities.MessageChannel
 ;%0Aim
@@ -1153,24 +1153,50 @@
  != null) %7B%0A
+                try %7B%0A    
             
@@ -1239,19 +1239,362 @@
     
-%7D%0A        %7D
+    %7D catch (Exception e) %7B%0A                    MessageSenderHelper.sendMessage(getChannel(Reference.OCW_DEBUG_CHANNEL), e.getStackTrace().toString());%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    private MessageChannel getChannel(String channel) %7B%0A        return Ninbot.getJda().getGuildById(Reference.OCW_SERVER_ID).getTextChannelById(channel);
 %0A   

Add exception handling