Class GenericGuildMessageReactionEvent
- java.lang.Object
-
- net.dv8tion.jda.api.events.Event
-
- net.dv8tion.jda.api.events.guild.GenericGuildEvent
-
- net.dv8tion.jda.api.events.message.guild.GenericGuildMessageEvent
-
- net.dv8tion.jda.api.events.message.guild.react.GenericGuildMessageReactionEvent
-
- All Implemented Interfaces:
GenericEvent
- Direct Known Subclasses:
GuildMessageReactionAddEvent
,GuildMessageReactionRemoveEvent
public abstract class GenericGuildMessageReactionEvent extends GenericGuildMessageEvent
Indicates that aMessageReaction
was added or removed in a TextChannel.Can be used to detect when a reaction is added or removed in a TextChannel.
Requirements
These events require the
GUILD_MESSAGE_REACTIONS
intent to be enabled.
-
-
Constructor Summary
Constructors Constructor Description GenericGuildMessageReactionEvent(JDA api, long responseNumber, Member user, MessageReaction reaction, long userId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Member
getMember()
TheMember
instance for the reacting user
This might be missing if the user was not previously cached or the member was removed.MessageReaction
getReaction()
TheMessageReaction
MessageReaction.ReactionEmote
getReactionEmote()
User
getUser()
The reactingUser
This might be missing if the user was not previously cached or the member was removed.java.lang.String
getUserId()
The id for the user who owns the reaction.long
getUserIdLong()
The id for the user who owns the reaction.RestAction<Member>
retrieveMember()
Retrieves theMember
who owns the reaction.RestAction<Message>
retrieveMessage()
Retrieves the message for this reaction event.RestAction<User>
retrieveUser()
Retrieves theUser
who owns the reaction.-
Methods inherited from class net.dv8tion.jda.api.events.message.guild.GenericGuildMessageEvent
getChannel, getMessageId, getMessageIdLong
-
Methods inherited from class net.dv8tion.jda.api.events.guild.GenericGuildEvent
getGuild
-
Methods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getResponseNumber
-
-
-
-
Constructor Detail
-
GenericGuildMessageReactionEvent
public GenericGuildMessageReactionEvent(@Nonnull JDA api, long responseNumber, @Nullable Member user, @Nonnull MessageReaction reaction, long userId)
-
-
Method Detail
-
getUserId
@Nonnull public java.lang.String 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 the reaction.- Returns:
- The user id
-
getUser
@Nullable public User getUser()
The reactingUser
This might be missing if the user was not previously cached or the member was removed. UseretrieveUser()
to load the user.- Returns:
- The reacting user or null if this information is missing
- See Also:
getUserIdLong()
-
getMember
@Nullable public Member getMember()
TheMember
instance for the reacting user
This might be missing if the user was not previously cached or the member was removed. UseretrieveMember()
to load the member.- Returns:
- The member instance for the reacting user or null if this information is missing
-
getReaction
@Nonnull public MessageReaction getReaction()
TheMessageReaction
- Returns:
- The message reaction
-
getReactionEmote
@Nonnull public MessageReaction.ReactionEmote getReactionEmote()
- Returns:
- The reaction emote
-
retrieveUser
@Nonnull @CheckReturnValue public RestAction<User> retrieveUser()
- Returns:
RestAction
- Type:User
- Since:
- 4.2.1
-
retrieveMember
@Nonnull @CheckReturnValue public RestAction<Member> retrieveMember()
Retrieves theMember
who owns the reaction.
If a member is known, this will returngetMember()
.Note that banning a member will also fire
GuildMessageReactionRemoveEvent
and no member will be available in those cases. AnUNKNOWN_MEMBER
error response should be the failure result.- Returns:
RestAction
- Type:Member
- Since:
- 4.2.1
-
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. To retrieve the member you can usegetGuild().retrieveMember(message.getAuthor())
.- Returns:
RestAction
- Type:Message
- Since:
- 4.2.1
-
-