-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventListener.java
39 lines (36 loc) · 1.44 KB
/
EventListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.mycompany.greenninja.listeners;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.jetbrains.annotations.NotNull;
/**
*
* @author Abhinav Pothuri
*/
public class EventListener extends ListenerAdapter
{
@Override
public void onMessageReactionAdd(@NotNull MessageReactionAddEvent event)
{
User user = event.getUser();
String emoji = event.getReaction().getEmoji().getAsReactionCode();
String channelMention = event.getChannel().getAsMention();
String response = user.getAsMention() + " reacted to a message" + " with " + emoji + " in " + channelMention + ".";
event.getChannel().sendMessage(response).queue();
}
@Override
public void onMessageReceived(@NotNull MessageReceivedEvent event)
{
String message = event.getMessage().getContentRaw();
if(message.contains("$Ping"))
{
event.getChannel().sendMessage("Pong").queue();
}
}
}