I'm trying to create a discord bot with java maven and I would like to have the core separated from the commands, and that the core call (start) the commands so that they can be used, I tried to call it in the following way but not it works, it gives me an error of java.lang.NullPoinerException I would appreciate someone helping me:
THE NUCLEUS
package darkdragon.team.dragonoid;
import net.dv8tion.jda.core.AccountType;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.JDABuilder;
import net.dv8tion.jda.core.entities.Game;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
public class App extends ListenerAdapter
{
public static JDA api;
public static void main( String[] args ) throws Exception
{
api = new JDABuilder(AccountType.BOT).setToken(Ref.token).buildBlocking();
api.addEventListener(new App());
api.getPresence().setGame(Game.playing("MANTENIMIENTO"));
MessageReceivedEvent evt = null;
Commands.processCommand(evt);
}
}
THE COMMANDS
package darkdragon.team.dragonoid;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.MessageChannel;
import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
public class Commands extends ListenerAdapter {
public static void processCommand(MessageReceivedEvent evt) {
User objUser = evt.getAuthor();
Message objMsg = evt.getMessage();
MessageChannel objMsgCh = evt.getChannel();
String[] command = objMsg.getContentRaw().toLowerCase().replaceFirst(Ref.prefix, "").split(" ");
if(command[0].equals("ping")) {
objMsgCh.sendMessage(objUser.getAsMention() + "Pong!");
}
}
}
SKIP THE ERROR
Exception in thread "main" java.lang.NullPointerException