started work on Member class

milan
Shwoomple 2022-02-20 23:11:38 +05:30
parent 22e0139466
commit 92f66779c1
2 changed files with 26 additions and 0 deletions

View File

@ -17,6 +17,9 @@ 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")) {

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