package com.robothand.highqualitybot.Command;

import com.robothand.highqualitybot.Bot;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.MessageChannel;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;

/**
 * Created by ethan on 6/17/17.
 */
public abstract class Command extends ListenerAdapter {
    Message message;
    String content;
    MessageChannel channel;

    public abstract void onCommand(MessageReceivedEvent event);

    @Override
    public void onMessageReceived(MessageReceivedEvent event) {
        // grab basic info from event
        message = event.getMessage();
        content = message.getRawContent();
        channel = message.getChannel();

        // check for command prefix
        if (content.startsWith(Bot.PREFIX)) {
            onCommand(event);
        }
    }
}

@@ -131,61 +131,8 @@
 ge;%0A
-import net.dv8tion.jda.core.entities.MessageChannel;%0A
 impo
@@ -344,77 +344,137 @@
 r %7B%0A
+%0A
     
-Message message;%0A    String content;%0A    MessageChannel channel;%0A
+public abstract String%5B%5D getNames();%0A    public abstract String getDescription();%0A    public abstract String getShortDesc();
 %0A   
@@ -531,16 +531,31 @@
 nt event
+, String%5B%5D args
 );%0A%0A    
@@ -674,16 +674,24 @@
         
+Message 
 message 
@@ -720,16 +720,23 @@
         
+String 
 content 
@@ -765,48 +765,8 @@
 t();
-%0A        channel = message.getChannel();
 %0A%0A  
@@ -811,16 +811,17 @@
     if (
+!
 content.
@@ -862,25 +862,379 @@
     
-onCommand(event);
+// strip it off and split it%0A            String%5B%5D args = content.replaceFirst(Bot.PREFIX, %22%22).split(%22 %22);%0A%0A            // check with names%0A            for (String current : getNames()) %7B%0A                if (args%5B0%5D.equals(current)) %7B%0A                    onCommand(event, args); // run command if we find the name%0A                    break;%0A                %7D%0A            %7D
 %0A   

add more functionality to Commands, split Ping and Shutdown