diff --git a/src/main/java/linux/general/hackyquizbot/Main.java b/src/main/java/linux/general/hackyquizbot/Main.java index ada3bfb..fe62353 100644 --- a/src/main/java/linux/general/hackyquizbot/Main.java +++ b/src/main/java/linux/general/hackyquizbot/Main.java @@ -4,6 +4,7 @@ import org.javacord.api.DiscordApi; import org.javacord.api.DiscordApiBuilder; import java.io.File; import java.io.FileNotFoundException; +import java.util.ArrayList; import java.util.Date; import java.util.Scanner; @@ -25,16 +26,19 @@ public class Main { DiscordApi api = new DiscordApiBuilder().setToken(commandLineArguments[0]).login().join(); - //Trivia management - Member member = new Member(api); + //user management + ArrayList QuizHandlers = new ArrayList(); - // small status command + // commands api.addMessageCreateListener(event -> { if (event.getMessageContent().equalsIgnoreCase("!ping")) { event.getChannel().sendMessage("Pong!\nHacky the quiz bot has been running since "+startupTime); } + if (event.getMessageContent().equalsIgnoreCase("!trivia")) { + QuizHandlers.add(new QuizHandler(api, event.getMessageAuthor().asUser().get())); + } }); - + } public static String getCommandLineArgument(int index) { diff --git a/src/main/java/linux/general/hackyquizbot/Member.java b/src/main/java/linux/general/hackyquizbot/QuizHandler.java similarity index 61% rename from src/main/java/linux/general/hackyquizbot/Member.java rename to src/main/java/linux/general/hackyquizbot/QuizHandler.java index 13aba9e..c6b9691 100644 --- a/src/main/java/linux/general/hackyquizbot/Member.java +++ b/src/main/java/linux/general/hackyquizbot/QuizHandler.java @@ -5,21 +5,14 @@ import org.javacord.api.entity.user.User; import org.javacord.api.entity.message.embed.EmbedBuilder; //TODO: find a better name for this class -public class Member { +public class QuizHandler { private DiscordApi api; private User user; - public Member(DiscordApi api) { + public QuizHandler(DiscordApi api, User user) { this.api = api; - - this.api.addMessageCreateListener(event ->{ - if(event.getMessageContent().equalsIgnoreCase("!trivia")) { - if(event.getMessageAuthor().asUser().isPresent()) { - this.user = event.getMessageAuthor().asUser().get(); - this.user.sendMessage("Hi! I'm Hacky! **Fuck you**! :D"); - } - } - }); + this.user = user; + user.sendMessage("Hi! I’m Hacky.\nThis is a test."); } public void sendMessage(String question, String[] options) {