testing reaction
parent
3f36573c19
commit
38803d519d
|
@ -15,6 +15,9 @@ public class QuizBackend {
|
||||||
private static Connection dbConnection;
|
private static Connection dbConnection;
|
||||||
private static Statement statement;
|
private static Statement statement;
|
||||||
|
|
||||||
|
// temporary hack to get something working
|
||||||
|
private static boolean once = true;
|
||||||
|
|
||||||
// CREATE TABLE questions(id INT(32) AUTO_INCREMENT PRIMARY KEY, question TEXT, max_score INT(8));
|
// CREATE TABLE questions(id INT(32) AUTO_INCREMENT PRIMARY KEY, question TEXT, max_score INT(8));
|
||||||
// CREATE TABLE answer_choices(id INT(32), answer VARCHAR(2048), correctness BOOLEAN);
|
// CREATE TABLE answer_choices(id INT(32), answer VARCHAR(2048), correctness BOOLEAN);
|
||||||
// CREATE TABLE user_answers(id INT(32), given_answer VARCHAR(2048), discord_user VARCHAR(1024));
|
// CREATE TABLE user_answers(id INT(32), given_answer VARCHAR(2048), discord_user VARCHAR(1024));
|
||||||
|
@ -62,6 +65,10 @@ public class QuizBackend {
|
||||||
|
|
||||||
//TODO: function to determine whether a user should get more questions
|
//TODO: function to determine whether a user should get more questions
|
||||||
public static boolean shouldGetMoreQuestions(String discordUserID) {
|
public static boolean shouldGetMoreQuestions(String discordUserID) {
|
||||||
|
if (once) {
|
||||||
|
once=false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package linux.general.hackyquizbot;
|
package linux.general.hackyquizbot;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import org.javacord.api.entity.emoji.Emoji;
|
||||||
|
import org.javacord.api.entity.message.Message;
|
||||||
import org.javacord.api.entity.user.User;
|
import org.javacord.api.entity.user.User;
|
||||||
|
|
||||||
import linux.general.hackyquizbot.QuizBackend.Question;
|
import linux.general.hackyquizbot.QuizBackend.Question;
|
||||||
|
@ -11,13 +15,26 @@ public class QuizHandler {
|
||||||
public QuizHandler(User user) {
|
public QuizHandler(User user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
if (QuizBackend.shouldGetMoreQuestions(user.getIdAsString())) {
|
if (QuizBackend.shouldGetMoreQuestions(user.getIdAsString())) {
|
||||||
user.sendMessage("Hi! I'm Hacky.\n"
|
try {
|
||||||
+ "I will be sending you a bunch of multiple-choice questions. "
|
Message message = user.sendMessage("Hi! I'm Hacky.\n"
|
||||||
+ "You can answer by selecting one or more of the reactions on the message and confirm your selection by selecting the :white_check_mark: reaction."
|
+ "I will be sending you a bunch of multiple-choice questions. "
|
||||||
+ " Please contact @BodgeMaster#0344 if there are any issues.\n"
|
+ "You can answer by selecting one or more of the reactions on the message and confirm your selection by selecting the :white_check_mark: reaction."
|
||||||
+ "\n"
|
+ " Please contact @BodgeMaster#0344 if there are any issues.\n"
|
||||||
+ "Select the :white_check_mark: reaction to continue.");
|
+ "\n"
|
||||||
|
+ "Select the :white_check_mark: reaction to continue.").get();
|
||||||
|
message.addReaction("✅");
|
||||||
|
message.addReactionAddListener(event -> {
|
||||||
|
if (event.getReaction().get().getEmoji().equalsEmoji("✅")) {
|
||||||
|
event.getMessage().get().getChannel().sendMessage("test");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
System.err.println("Something went wrong while trying to get the sent message object.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
//TODO: add white question mark reaction
|
//TODO: add white question mark reaction
|
||||||
|
|
||||||
//TODO: add reaction handler (preferably to channel?)
|
//TODO: add reaction handler (preferably to channel?)
|
||||||
} else {
|
} else {
|
||||||
user.sendMessage(
|
user.sendMessage(
|
||||||
|
|
Loading…
Reference in New Issue