Merge branch 'master' into bodgemaster

bodgemaster
BodgeMaster 2022-02-20 19:18:07 +01:00
commit 88014c726d
2 changed files with 30 additions and 1 deletions

View File

@ -4,11 +4,14 @@ 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.Date;
import java.util.Scanner; import java.util.Scanner;
public class Main { public class Main {
public static void main(String[] args) { 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 // Insert your bot's token here
String token = args[0]; String token = args[0];
@ -16,11 +19,14 @@ public class Main {
check.start(); check.start();
DiscordApi api = new DiscordApiBuilder().setToken(token).login().join(); 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" // Add a listener which answers with "Pong!" if someone writes "!ping"
api.addMessageCreateListener(event -> { api.addMessageCreateListener(event -> {
if (event.getMessageContent().equalsIgnoreCase("!ping")) { if (event.getMessageContent().equalsIgnoreCase("!ping")) {
event.getChannel().sendMessage("Pong!"); event.getChannel().sendMessage("Pong!\nHacky the quiz bot has been running since "+startupTime);
} }
}); });

View File

@ -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");
}
}
});
}
}