reworked how users are handled
parent
d5201044ec
commit
113323da00
|
@ -4,6 +4,7 @@ import org.javacord.api.DiscordApi;
|
||||||
import org.javacord.api.DiscordApiBuilder;
|
import org.javacord.api.DiscordApiBuilder;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
@ -25,14 +26,17 @@ public class Main {
|
||||||
|
|
||||||
DiscordApi api = new DiscordApiBuilder().setToken(commandLineArguments[0]).login().join();
|
DiscordApi api = new DiscordApiBuilder().setToken(commandLineArguments[0]).login().join();
|
||||||
|
|
||||||
//Trivia management
|
//user management
|
||||||
Member member = new Member(api);
|
ArrayList<QuizHandler> QuizHandlers = new ArrayList<QuizHandler>();
|
||||||
|
|
||||||
// small status command
|
// commands
|
||||||
api.addMessageCreateListener(event -> {
|
api.addMessageCreateListener(event -> {
|
||||||
if (event.getMessageContent().equalsIgnoreCase("!ping")) {
|
if (event.getMessageContent().equalsIgnoreCase("!ping")) {
|
||||||
event.getChannel().sendMessage("Pong!\nHacky the quiz bot has been running since "+startupTime);
|
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()));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,21 +5,14 @@ import org.javacord.api.entity.user.User;
|
||||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||||
|
|
||||||
//TODO: find a better name for this class
|
//TODO: find a better name for this class
|
||||||
public class Member {
|
public class QuizHandler {
|
||||||
private DiscordApi api;
|
private DiscordApi api;
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
public Member(DiscordApi api) {
|
public QuizHandler(DiscordApi api, User user) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
this.user = user;
|
||||||
this.api.addMessageCreateListener(event ->{
|
user.sendMessage("Hi! I’m Hacky.\nThis is a test.");
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(String question, String[] options) {
|
public void sendMessage(String question, String[] options) {
|
Loading…
Reference in New Issue