Class GenericMessageReactionEvent
java.lang.Object
net.dv8tion.jda.api.events.Event
net.dv8tion.jda.api.events.message.GenericMessageEvent
net.dv8tion.jda.api.events.message.react.GenericMessageReactionEvent
- All Implemented Interfaces:
GenericEvent
- Direct Known Subclasses:
MessageReactionAddEvent
,MessageReactionRemoveEvent
Indicates that a MessageReaction was added/removed.
Every MessageReactionEvent is derived from this event and can be casted.
Every MessageReactionEvent is derived from this event and can be casted.
Can be used to detect both remove and add events.
Requirements
These events require at least one of the following intents (Will not fire at all if neither is enabled):
GUILD_MESSAGE_REACTIONS
to work in guild text channelsDIRECT_MESSAGE_REACTIONS
to work in private channels
-
Constructor Summary
ConstructorDescriptionGenericMessageReactionEvent
(JDA api, long responseNumber, User user, Member member, MessageReaction reaction, long userId) -
Method Summary
Modifier and TypeMethodDescriptiongetEmoji()
TheEmoji
of the reaction, shortcut forgetReaction().getEmoji()
TheMember
instance for the reacting user ornull
if the reaction was from a user not in this guild.TheMessageReaction
getUser()
The reactingUser
This might be missing if the user was not cached.The id for the user who owns the reaction.long
The id for the user who owns reaction.Retrieves theMember
who owns the reaction.Retrieves the message for this reaction event.Retrieves theUser
who owns the reaction.Methods inherited from class net.dv8tion.jda.api.events.message.GenericMessageEvent
getChannel, getChannelType, getGuild, getGuildChannel, getJumpUrl, getMessageId, getMessageIdLong, isFromGuild, isFromThread, isFromType
Methods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getRawData, getResponseNumber, toString
-
Constructor Details
-
GenericMessageReactionEvent
-
-
Method Details
-
getUserId
The id for the user who owns the reaction.- Returns:
- The user id
-
getUserIdLong
public long getUserIdLong()The id for the user who owns reaction.- Returns:
- The user id
-
getUser
The reactingUser
This might be missing if the user was not cached. UseretrieveUser()
to load the user.- Returns:
- The reacting user or null if this information is missing
-
getMember
TheMember
instance for the reacting user ornull
if the reaction was from a user not in this guild.
This will also benull
if the member is not available in the cache. UseretrieveMember()
to load the member.- Returns:
- Member of the reacting user or null if they are no longer member of this guild
- Throws:
IllegalStateException
- If this was not sent in aGuild
.- See Also:
-
getReaction
TheMessageReaction
- Returns:
- The MessageReaction
-
getEmoji
TheEmoji
of the reaction, shortcut forgetReaction().getEmoji()
- Returns:
- The Emoji instance
-
retrieveUser
- Returns:
RestAction
- Type:User
- Since:
- 4.2.1
-
retrieveMember
Retrieves theMember
who owns the reaction.
If a member is known, this will returngetMember()
.Note that banning a member will also fire
MessageReactionRemoveEvent
and no member will be available in those cases. AnUNKNOWN_MEMBER
error response should be the failure result.- Returns:
RestAction
- Type:Member
- Throws:
IllegalStateException
- If this event is not from a guild- Since:
- 4.2.1
-
retrieveMessage
Retrieves the message for this reaction event.
Simple shortcut forgetChannel().retrieveMessageById(getMessageId())
.The
Message.getMember()
method will always return null for the resulting message. To retrieve the member you can usegetGuild().retrieveMember(message.getAuthor())
.- Returns:
RestAction
- Type:Message
- Since:
- 4.2.1
-