Updated Commands
This commit is contained in:
parent
b9eb6ea83d
commit
c830cab0ed
7 changed files with 36 additions and 12 deletions
|
|
@ -17,6 +17,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
public class Hadder {
|
||||
|
||||
|
|
@ -44,12 +45,8 @@ public class Hadder {
|
|||
builder.setActivity(Activity.streaming("auf dem BigBotNetwork", "https://twitch.tv/BigBotNetwork"));
|
||||
builder.setToken(config.getString("Token"));
|
||||
|
||||
CommandHandler.cmdlist.put("test", new TestCommand());
|
||||
CommandHandler.cmdlist.put("ban", new BanCommand());
|
||||
CommandHandler.cmdlist.put("prefix", new PrefixCommand());
|
||||
CommandHandler.cmdlist.put("stop", new ShutdownCommand());
|
||||
CommandHandler.cmdlist.put("shutdown", new ShutdownCommand());
|
||||
CommandHandler.cmdlist.put("kick", new KickCommand());
|
||||
|
||||
CommandHandler.cmdlist.addAll(List.of(new TestCommand(), new BanCommand(), new PrefixCommand(), new ShutdownCommand(), new KickCommand()));
|
||||
|
||||
builder.addEventListeners(
|
||||
new MentionListener(),
|
||||
|
|
|
|||
|
|
@ -8,4 +8,5 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
|||
|
||||
public interface Command {
|
||||
void executed(String[] args, MessageReceivedEvent event);
|
||||
String[] labels();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,4 +11,9 @@ public class TestCommand implements Command {
|
|||
public void executed(String[] args, MessageReceivedEvent event) {
|
||||
event.getTextChannel().sendMessage("TEST my friends").queue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] labels() {
|
||||
return new String[]{"test"};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,4 +48,9 @@ public class BanCommand implements Command {
|
|||
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.NO_PERMISSION, builder).build()).queue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] labels() {
|
||||
return new String[]{"ban"};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,20 @@ public class ShutdownCommand implements Command {
|
|||
if (event.getAuthor().getId().equals("477141528981012511") || event.getAuthor().getId().equals("261083609148948488")) {
|
||||
EmbedBuilder builder = new EmbedBuilder();
|
||||
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.INFO, builder).setTitle("Shutdown").build()).queue();
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
event.getJDA().shutdown();
|
||||
Rethink.disconnect();
|
||||
} else {
|
||||
EmbedBuilder builder = new EmbedBuilder();
|
||||
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.NO_PERMISSION, builder).build()).queue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] labels() {
|
||||
return new String[]{"shutdown"};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,4 +36,9 @@ public class PrefixCommand implements Command {
|
|||
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.NO_PERMISSION, builder).build()).queue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] labels() {
|
||||
return new String[]{"prefix"};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,16 +6,18 @@ package com.bbn.hadder.core;
|
|||
|
||||
import com.bbn.hadder.commands.Command;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CommandHandler {
|
||||
|
||||
public static HashMap<String, Command> cmdlist = new HashMap<>();
|
||||
public static ArrayList<Command> cmdlist = new ArrayList<>();
|
||||
|
||||
public static void handleCommand(CommandParser.commandContainer cmd) {
|
||||
if(cmdlist.containsKey(cmd.invoke)) {
|
||||
cmdlist.get(cmd.invoke).executed(cmd.args, cmd.event);
|
||||
for (Command command : cmdlist) {
|
||||
for (String label : command.labels()) {
|
||||
if (label.equals(cmd.invoke)) command.executed(cmd.args, cmd.event);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue