From 92f66779c1ea7789b7c7f8ec9a10a49ee975a971 Mon Sep 17 00:00:00 2001 From: Shwoomple Date: Sun, 20 Feb 2022 23:11:38 +0530 Subject: [PATCH 1/2] started work on Member class --- .../java/linux/general/hackyquizbot/Main.java | 3 +++ .../linux/general/hackyquizbot/Member.java | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/main/java/linux/general/hackyquizbot/Member.java diff --git a/src/main/java/linux/general/hackyquizbot/Main.java b/src/main/java/linux/general/hackyquizbot/Main.java index f2c0fe8..ac82969 100644 --- a/src/main/java/linux/general/hackyquizbot/Main.java +++ b/src/main/java/linux/general/hackyquizbot/Main.java @@ -16,6 +16,9 @@ public class Main { check.start(); DiscordApi api = new DiscordApiBuilder().setToken(token).login().join(); + + //Trivia management + Member member = new Member(api); // Add a listener which answers with "Pong!" if someone writes "!ping" api.addMessageCreateListener(event -> { diff --git a/src/main/java/linux/general/hackyquizbot/Member.java b/src/main/java/linux/general/hackyquizbot/Member.java new file mode 100644 index 0000000..0e18952 --- /dev/null +++ b/src/main/java/linux/general/hackyquizbot/Member.java @@ -0,0 +1,23 @@ +package linux.general.hackyquizbot; + +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.user.User; + +public class Member { + private DiscordApi api; + private User user; + + public Member(DiscordApi api) { + 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("Welcome to hell"); + } + } + }); + } +} From 461fbab6f0345cf40cd8d093e32261e4ad9ac6fc Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sun, 20 Feb 2022 19:13:49 +0100 Subject: [PATCH 2/2] make ping command reflect startup time --- src/main/java/linux/general/hackyquizbot/Main.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/linux/general/hackyquizbot/Main.java b/src/main/java/linux/general/hackyquizbot/Main.java index ac82969..f06af9d 100644 --- a/src/main/java/linux/general/hackyquizbot/Main.java +++ b/src/main/java/linux/general/hackyquizbot/Main.java @@ -4,11 +4,14 @@ import org.javacord.api.DiscordApi; import org.javacord.api.DiscordApiBuilder; import java.io.File; import java.io.FileNotFoundException; +import java.util.Date; import java.util.Scanner; public class Main { public static void main(String[] args) { + String startupTime = String.format("%1$tY-%1$tm-%1$td %1$tI:%1$tM:%1$tS%1$tp UTC%1$tz", new Date()); + // Insert your bot's token here String token = args[0]; @@ -23,7 +26,7 @@ public class Main { // Add a listener which answers with "Pong!" if someone writes "!ping" api.addMessageCreateListener(event -> { if (event.getMessageContent().equalsIgnoreCase("!ping")) { - event.getChannel().sendMessage("Pong!"); + event.getChannel().sendMessage("Pong!\nHacky the quiz bot has been running since "+startupTime); } });