Merge branch 'master' into bodgemaster
commit
88014c726d
|
@ -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];
|
||||||
|
|
||||||
|
@ -17,10 +20,13 @@ public class Main {
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue