Class MessageReaction
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionMessageReaction(JDA jda, MessageChannel channel, EmojiUnion emoji, long channelId, long messageId, boolean[] self, int[] counts) Creates a new MessageReaction instance -
Method Summary
Modifier and TypeMethodDescriptionRemoves this entire reaction from the message.booleanTheMessageChannelthis Reaction was used in.The ID for the channel this reaction happened in.longThe ID for the channel this reaction happened in.TheChannelTypethis Reaction was used in.intgetCount()The total amount of users that already reacted with this Reaction.intThe specific amount of users that already reacted with this Reaction.getEmoji()TheEmojiof this Reaction.getGuild()TheGuildthis Reaction was used in.Thechannelthis Reaction was used in.getJDA()The JDA instance of this ReactionThe message id this reaction is attached tolongThe message id this reaction is attached tobooleanWhether this reaction instance has an availablegetChannel().booleanhasCount()Whether this reaction can provide a count viagetCount().booleanisFromType(ChannelType type) Whether this Reaction was used in aMessageChannelof the specifiedChannelType.booleanisSelf()Whether the currently logged in account has reacted with this reaction at all, including both super and normal.booleanWhether the currently logged in account has reacted with this reaction as specifically a super or normal reaction.Removes this Reaction from the Message.removeReaction(User user) Removes this Reaction from the Message.Retrieves theUsersthat already reacted with this MessageReaction.toString()
-
Constructor Details
-
MessageReaction
public MessageReaction(@Nonnull JDA jda, @Nullable MessageChannel channel, @Nonnull EmojiUnion emoji, long channelId, long messageId, boolean[] self, int[] counts) Creates a new MessageReaction instance- Parameters:
channel- TheMessageChannelthis Reaction was used inemoji- TheEmojithat was usedchannelId- The channel id for this reactionmessageId- The message id this reaction is attached toself- Whether we already reacted with this Reaction, as an array of[normal, super]counts- The amount of people that reacted with this Reaction, as an array of[total, normal, super]
-
-
Method Details
-
getJDA
The JDA instance of this Reaction- Returns:
- The JDA instance of this Reaction
-
isSelf
public boolean isSelf()Whether the currently logged in account has reacted with this reaction at all, including both super and normal.This will always be false for events. Discord does not provide this information for reaction events. You can use
MessageChannel.retrieveMessageById(String)to get this information on a complete message.- Returns:
- True, if we reacted with this reaction
- See Also:
-
isSelf
Whether the currently logged in account has reacted with this reaction as specifically a super or normal reaction.This will always be false for events. Discord does not provide this information for reaction events. You can use
MessageChannel.retrieveMessageById(String)to get this information on a complete message.- Parameters:
type- The specific type of reaction- Returns:
- True, if we reacted with this reaction
-
hasCount
public boolean hasCount()Whether this reaction can provide a count viagetCount().
This is usually not provided for reactions coming fromMessageReactionAddEventor similar.- Returns:
- True, if a count is available
- See Also:
-
hasChannel
public boolean hasChannel()Whether this reaction instance has an availablegetChannel().This can be
falsefor messages sent via webhooks, or in the context of interactions.- Returns:
- True, if
getChannel()is available
-
getCount
public int getCount()The total amount of users that already reacted with this Reaction.
This is not updated, it is afinal intper Reaction instanceThis value is not available in events such as
MessageReactionAddEventandMessageReactionRemoveEventin which case anIllegalStateExceptionis thrown!- Returns:
- The amount of users that reacted with this Reaction
- Throws:
IllegalStateException- If this MessageReaction is from an event which does not provide a count- See Also:
-
getCount
The specific amount of users that already reacted with this Reaction.
This is not updated, it is afinal intper Reaction instanceThis value is not available in events such as
MessageReactionAddEventandMessageReactionRemoveEventin which case anIllegalStateExceptionis thrown!- Parameters:
type- The specific type of reaction- Returns:
- The amount of users that reacted with this Reaction
- Throws:
IllegalStateException- If this MessageReaction is from an event which does not provide a count- See Also:
-
getChannelType
TheChannelTypethis Reaction was used in.- Returns:
- The ChannelType
-
isFromType
Whether this Reaction was used in aMessageChannelof the specifiedChannelType.- Parameters:
type- The ChannelType to compare- Returns:
- True, if this Reaction was used in a MessageChannel from the specified ChannelType
-
getGuild
TheGuildthis Reaction was used in.- Returns:
Guildthis Reaction was used in- Throws:
IllegalStateException- IfgetChannel()is not a guild channel or the channel is not provided
-
getChannel
TheMessageChannelthis Reaction was used in.- Returns:
- The channel this Reaction was used in
- Throws:
IllegalStateException- If no channel instance is provided, this might be missing for messages sent from webhooks.
-
getGuildChannel
Thechannelthis Reaction was used in.- Returns:
- The guild channel this Reaction was used in
- Throws:
IllegalStateException- IfgetChannel()is not a guild channel or the channel is not provided
-
getChannelIdLong
public long getChannelIdLong()The ID for the channel this reaction happened in.- Returns:
- The channel id
-
getChannelId
The ID for the channel this reaction happened in.- Returns:
- The channel id
-
getEmoji
- Returns:
- The final instance of this Reaction's Emoji
-
getMessageId
The message id this reaction is attached to- Returns:
- The message id this reaction is attached to
-
getMessageIdLong
public long getMessageIdLong()The message id this reaction is attached to- Returns:
- The message id this reaction is attached to
-
retrieveUsers
Retrieves theUsersthat already reacted with this MessageReaction.Possible ErrorResponses include:
UNKNOWN_MESSAGE
If the message this reaction was attached to got deleted.UNKNOWN_CHANNEL
If the channel this reaction was used in got deleted.MISSING_ACCESS
If we were removed from the channel/guild
- Returns:
ReactionPaginationAction
-
removeReaction
Removes this Reaction from the Message.
This will remove our own reaction as an overload ofremoveReaction(User).Possible ErrorResponses include:
UNKNOWN_MESSAGE
If the message this reaction was attached to got deleted.UNKNOWN_CHANNEL
If the channel this reaction was used in got deleted.MISSING_ACCESS
If we were removed from the channel/guild
- Returns:
RestAction- Type: Void Nothing is returned on success
-
removeReaction
Removes this Reaction from the Message.
This will remove the reaction of theUserprovided.If the provided User did not react with this Reaction this does nothing.
Possible ErrorResponses include:
UNKNOWN_MESSAGE
If the message this reaction was attached to got deleted.UNKNOWN_CHANNEL
If the channel this reaction was used in got deleted.MISSING_ACCESS
If we were removed from the channel/guild
- Parameters:
user- The User of which to remove the reaction- Returns:
RestActionNothing is returned on success- Throws:
IllegalArgumentException- If the provideduseris null.InsufficientPermissionException- If the provided User is not us and we do not have permission tomanage messagesin the channel this reaction was used inPermissionException- If the message is from another user in aPrivateChannel
-
clearReactions
Removes this entire reaction from the message.
UnlikeremoveReaction(User), which removes the reaction of a single user, this will remove the reaction completely.The following
ErrorResponsesare possible:MISSING_ACCESS
The currently logged in account lost access to the channel by either being removed from the guild or losing theVIEW_CHANNELpermissionUNKNOWN_EMOJI
The provided unicode emoji doesn't exist. Try using one of the example formats.UNKNOWN_MESSAGE
The message was deleted.
- Returns:
RestAction- Throws:
UnsupportedOperationException- If this reaction happened in a private channelInsufficientPermissionException- If the currently logged in account does not havePermission.MESSAGE_MANAGEin the channel- Since:
- 4.2.0
-
equals
-
toString
-