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
public class GenericMessageReactionEvent extends GenericMessageEvent
Indicates that a MessageReaction was added/removed.
Every MessageReactionEvent is derived from this event and can be casted.Can be used to detect both remove and add events.
-
-
Constructor Summary
Constructors Constructor Description GenericMessageReactionEvent(JDA api, long responseNumber, User user, Member member, MessageReaction reaction, long userId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MembergetMember()TheMemberinstance for the reacting user ornullif the reaction was from a user not in this guild.MessageReactiongetReaction()TheMessageReactionMessageReaction.ReactionEmotegetReactionEmote()TheReactionEmoteof the reaction, shortcut forgetReaction().getReactionEmote()UsergetUser()The reactingUser
This might be missing if the user was not cached.StringgetUserId()The id for the user who added/removed their reaction.longgetUserIdLong()The id for the user who added/removed their reaction.RestAction<Member>retrieveMember()Retrieves theMemberwho added or removed the reaction.RestAction<Message>retrieveMessage()Retrieves the message for this reaction event.RestAction<User>retrieveUser()Retrieves theUserwho added or removed the reaction.-
Methods inherited from class net.dv8tion.jda.api.events.message.GenericMessageEvent
getChannel, getChannelType, getGuild, getMessageId, getMessageIdLong, getPrivateChannel, getTextChannel, isFromGuild, isFromType
-
Methods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getResponseNumber
-
-
-
-
Method Detail
-
getUserId
@Nonnull public String getUserId()
The id for the user who added/removed their reaction.- Returns:
- The user id
-
getUserIdLong
public long getUserIdLong()
The id for the user who added/removed their reaction.- Returns:
- The user id
-
getUser
@Nullable public User getUser()
The reactingUser
This might be missing if the user was not cached.- Returns:
- The reacting user or null if this information is missing
-
getMember
@Nullable public Member getMember()
TheMemberinstance for the reacting user ornullif the reaction was from a user not in this guild.- 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 aTextChannel.- See Also:
GenericMessageEvent.isFromGuild(),GenericMessageEvent.getChannelType()
-
getReaction
@Nonnull public MessageReaction getReaction()
TheMessageReaction- Returns:
- The MessageReaction
-
getReactionEmote
@Nonnull public MessageReaction.ReactionEmote getReactionEmote()
TheReactionEmoteof the reaction, shortcut forgetReaction().getReactionEmote()- Returns:
- The ReactionEmote instance
-
retrieveUser
@Nonnull @CheckReturnValue public RestAction<User> retrieveUser()
Retrieves theUserwho added or removed the reaction.
If a user is known, this will returngetUser().- Returns:
RestAction- Type:User
-
retrieveMember
@Nonnull @CheckReturnValue public RestAction<Member> retrieveMember()
Retrieves theMemberwho added or removed the reaction.
If a member is known, this will returngetMember().Note that banning a member will also fire
MessageReactionRemoveEventand no member will be available in those cases. AnUNKNOWN_MEMBERerror response should be the failure result.- Returns:
RestAction- Type:Member
-
retrieveMessage
@Nonnull @CheckReturnValue public RestAction<Message> 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. You can, instead, retrieve the member viagetMember()orretrieveMember().- Returns:
RestAction- Type:Message
-
-