This commit is contained in:
nora 2021-01-22 23:23:52 +01:00
parent a30e1653ca
commit e3a7db9b56
10 changed files with 150 additions and 29 deletions

View file

@ -15,17 +15,11 @@ public class Config {
public static final long KUKUROO_MOUNTAIN_ID = 799696420386504795L;
public static final long TRIVIA_APPROVAL_CHANNEL_ID = 802244298774413312L;
public static EmbedBuilder getDefaultEmbed() {
EmbedBuilder builder = new EmbedBuilder();
builder.setColor(Config.DEFAULT_COLOR);
return builder;
}
public static EmbedBuilder getDefaultEmbed(Event event) {
User killua = event.getJDA().getUserById(THIS_ID);
if (killua == null) {
event.getJDA().retrieveUserById(THIS_ID).queue(user -> {
System.out.println("[Config] " + user.getAsTag() + " successfully retrieved.");
System.out.println("[Config 22] " + user.getAsTag() + " successfully retrieved.");
});
System.err.println("[Config] This bot user not cached. Retrieving user...");

View file

@ -10,8 +10,6 @@ import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
import java.util.Objects;
public class TriviaApproval extends ReactionAdapter {
public static final String APPROVE_EMOTE = "\u2705"; //
@ -37,7 +35,7 @@ public class TriviaApproval extends ReactionAdapter {
message.addReaction(DENY_EMOTE).queue();
create(message.getIdLong());
ReactionEventManager.addMessage(message.getIdLong(), this);
System.out.println(ConsoleColors.BLUE + "[TriviaApproval 32] Trivia Question registered for approval" + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "[TriviaApproval 38] Trivia Question registered for approval" + ConsoleColors.RESET);
});
}
@ -46,10 +44,10 @@ public class TriviaApproval extends ReactionAdapter {
if (event.getUser() != null) {
if (event.getUser().getIdLong() == Config.NILS_ID) {
String emote = event.getReaction().getReactionEmote().getName();
System.out.println(ConsoleColors.BLUE + "[TriviaApproval 46] Received Emote " + emote + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "[TriviaApproval 47] Received Emote " + emote + ConsoleColors.RESET);
if (emote.equals(APPROVE_EMOTE)) {
event.getTextChannel().sendMessage("Question approved.").queue();
System.out.println(ConsoleColors.BLUE + "[TriviaApproval 55] Question Approved: " + question.getQuestion() + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "[TriviaApproval 50] Question Approved: " + question.getQuestion() + ConsoleColors.RESET);
TriviaQuestionData.add(question);
dispose();
} else if (emote.equals(DENY_EMOTE)) {

View file

@ -136,7 +136,7 @@ public class TriviaCommand extends Command {
new TriviaApproval(event, new TriviaQuestion(answers));
} else {
System.out.println(ConsoleColors.BLUE_BOLD + "[TriviaCommand.AddSection 121] Received Next Message: "
System.out.println(ConsoleColors.BLUE_BOLD + "[TriviaCommand.AddSection 139] Received Next Message: "
+ event.getMessage().getContentRaw() + " status: " + status + ConsoleColors.RESET);
answers[status] = event.getMessage().getContentRaw();
if (status >= 3) {

View file

@ -32,7 +32,7 @@ public class CommandHandler {
if (event.getMessage().getContentRaw().toLowerCase().startsWith(Config.PREFIX)) {
String[] split = parser.splitOffCommandName(event.getMessage().getContentRaw());
String command = split[0];
System.out.println(ConsoleColors.GREEN + "[CHandler] cmd: '" + command + "'" + " args: '" + split[1] + "'" + ConsoleColors.RESET);
System.out.println(ConsoleColors.GREEN + "[CHandler 35] cmd: '" + command + "'" + " args: '" + split[1] + "'" + ConsoleColors.RESET);
if (commands.containsKey(command)) {
commands.get(command).called(event, split[1]);
} else if (hiddenCommands.containsKey(command)) {
@ -75,7 +75,6 @@ public class CommandHandler {
i++;
}
System.out.println(Arrays.toString(builders));
MessageEmbed[] messageEmbeds = new MessageEmbed[pages];
for (i = 0; i < builders.length; i++) {
messageEmbeds[i] = builders[i].build();

View file

@ -37,10 +37,10 @@ public class Main {
JDA jda = builder.build();
setupCommands();
/* Thread t = new Thread(() -> {
Thread t = new Thread(() -> {
Scanner scanner = new Scanner(System.in);
String line = scanner.nextLine();
while (!line.equals("exit")) {
while (!line.equals("exit") && !line.equals("quit")) {
if (line.startsWith("send")) {
System.out.println("GuildID");
line = scanner.nextLine();
@ -57,16 +57,13 @@ public class Main {
}
}
}
} else if(line.startsWith("filetest")){
File f = new File("hallo.eric");
System.out.println(ConsoleColors.BLUE + "[TriviaQuestionData 80] File path " + f.getAbsolutePath() + ConsoleColors.RESET);
}
line = scanner.nextLine();
}
System.exit(0);
});
t.start();*/
t.start();
}
private static void setupCommands() {

View file

@ -10,7 +10,7 @@ public class CommandListener extends ListenerAdapter {
@Override
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
if (!event.getAuthor().isBot()) {
System.out.println(ConsoleColors.CYAN + "[CListener] Received message: '" +
System.out.println(ConsoleColors.CYAN + "[CListener 13] Received message: '" +
event.getMessage().getContentRaw() + "' by " + event.getAuthor().getAsTag() + ConsoleColors.RESET);
CommandHandler.call(event);
}

View file

@ -18,7 +18,7 @@ public class ReactionEventManager {
}
public static void onReactionAdd(MessageReactionAddEvent event){
System.out.println(ConsoleColors.PURPLE + "[ReactionEventManager] Reaction added: " + event.getReactionEmote() +
System.out.println(ConsoleColors.PURPLE + "[ReactionEventManager 21] Reaction added: " + event.getReactionEmote() +
" by " + event.getUser().getAsTag() + ConsoleColors.RESET);
long message = event.getMessageIdLong();
ReactionListener listener = currentReactions.get(message);
@ -28,7 +28,7 @@ public class ReactionEventManager {
}
public static void onReactionRemove(MessageReactionRemoveEvent event){
System.out.println(ConsoleColors.PURPLE + "[ReactionEventManager] Reaction removed: " + event.getReactionEmote() +
System.out.println(ConsoleColors.PURPLE + "[ReactionEventManager 31] Reaction removed: " + event.getReactionEmote() +
" by " + event.getUser().getAsTag() + ConsoleColors.RESET);
long message = event.getMessageIdLong();
ReactionListener listener = currentReactions.get(message);

View file

@ -27,7 +27,7 @@ public class ChannelMessageEventManager {
public static void onMessageReceived(MessageReceivedEvent event) {
long id = event.getTextChannel().getIdLong();
if (listeners.containsKey(id)) {
System.out.println(ConsoleColors.YELLOW + "[ChannelMsgEvtMgr] Message in listened channel " +
System.out.println(ConsoleColors.YELLOW + "[ChannelMsgEvtMgr 30] Message in listened channel " +
event.getTextChannel().getName() + " by " + event.getAuthor().getAsTag() + ": " + event.getMessage().getContentRaw() + ConsoleColors.RESET);
List<ChannelListener> list = listeners.get(id);
for (ChannelListener channelListener : list) {

View file

@ -4,6 +4,7 @@ import com.github.nilstrieb.util.ConsoleColors;
import com.google.gson.Gson;
import java.io.*;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@ -12,7 +13,18 @@ public class TriviaQuestionData {
static List<List<TriviaQuestion>> questions = new ArrayList<>();
private static final Random random = new Random();
private static final String JSON_PATH = "trivia_questions.json";
private static String JSON_PATH_JAR;
static {
try {
JSON_PATH_JAR = new File(TriviaQuestionData.class.getProtectionDomain().getCodeSource()
.getLocation().toURI()).getPath().replaceAll("(.*\\\\).*?\\.jar", "$1") + "trivia_questions.json";;
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
private static final String JSON_PATH_INTELLIJ = "trivia_questions.json";
private static final String JSON_PATH = JSON_PATH_JAR;
static {
questions.add(new ArrayList<>());
@ -22,13 +34,14 @@ public class TriviaQuestionData {
questions.add(new ArrayList<>());
questions.add(new ArrayList<>());
questions.add(new ArrayList<>());
System.out.println(ConsoleColors.BLUE + "[TriviaQuestionData 25] JSON File Path: " + new File(JSON_PATH + "hallo").getAbsolutePath() + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "[TriviaQuestionData 37] JSON File Path: " + new File(JSON_PATH + "hallo").getAbsolutePath() + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "[TriviaQuestionData 38] JSON File Path: " + JSON_PATH+ ConsoleColors.RESET);
loadJSON();
}
private static void loadJSON() {
System.out.println();
System.out.println("[TriviaQuestionData 44] Load JSON File");
StringBuilder json = new StringBuilder();
try (BufferedReader bufferedReader = new BufferedReader(

View file

@ -1 +1,121 @@
[{"question":"question","answers":["a","b","c","d"],"correctAnswer":0,"arc":0}]
[
{
"question": "What\u0027s the name of Gons aunt?",
"answers": [
"Kite",
"Mito",
"Ging",
"Kurapika"
],
"correctAnswer": 1,
"arc": 0
},
{
"question": "Why does Leorio want money?",
"answers": [
"To become a doctor",
"To send it to e-girls",
"So that others don\u0027t get it",
"To buy large quantities of drugs"
],
"correctAnswer": 0,
"arc": 0
},
{
"question": "What was Gon\u0027s aim after Killua left him alone playing with the Chairman Netero?",
"answers": [
"Get the ball",
"Make Netero use his right hand",
"Make Netero use his left leg",
"Let Netero drop the ball"
],
"correctAnswer": 1,
"arc": 0
},
{
"question": "What did Tonpa mix into the drink?",
"answers": [
"Sleeping pills",
"Headache tabletsschla",
"Laxative",
"Rat poison"
],
"correctAnswer": 2,
"arc": 0
},
{
"question": "How many doors are there at the Testing Gate of the Zoldyck Family?",
"answers": [
"7",
"5",
"12",
"8"
],
"correctAnswer": 0,
"arc": 1
},
{
"question": "What is Bisky\u0027s true form?",
"answers": [
"Boy",
"Big Woman",
"Little Girl"
],
"correctAnswer": 1,
"arc": 4
},
{
"question": "How did Gon die on Greed Island?",
"answers": [
"He didn\u0027t die on Greed Island",
"Hisoka killed him with a card to the neck",
"He lost too muich blood when Genthru blew his arm of",
"He killed himself after Killuas death"
],
"correctAnswer": 0,
"arc": 4
},
{
"question": "Where did Meruem die?",
"answers": [
"Volcano",
"In the desert with Netero",
"In the basement of the palace",
"In the womb of the queen"
],
"correctAnswer": 2,
"arc": 5
},
{
"question": "Who is Alluka?",
"answers": [
"Gon\u0027s sister",
"A Zodiac",
"The \u0027dark\u0027 side of Nanika",
"Killua\u0027s sister"
],
"correctAnswer": 3,
"arc": 6
},
{
"question": "What is Genthrus ability called?",
"answers": [
"Nuke",
"Massive Explosion",
"Little Flower"
],
"correctAnswer": 2,
"arc": 4
},
{
"question": "Who is not a member of the Zoldyck familiy?",
"answers": [
"Milluki",
"Killua",
"Ollaki",
"Illumi"
],
"correctAnswer": 2,
"arc": 1
}
]