Skip to content

Commit

Permalink
Add a way to retrieve users that used super reaction
Browse files Browse the repository at this point in the history
  • Loading branch information
MTM123 committed Dec 30, 2024
1 parent 93e788c commit 5c2e60c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
45 changes: 44 additions & 1 deletion src/main/java/net/dv8tion/jda/api/entities/MessageReaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ public long getMessageIdLong()
* </ul>
*
* @return {@link ReactionPaginationAction ReactionPaginationAction}
*
* @see #retrieveUsers(ReactionType)
*/
@Nonnull
@CheckReturnValue
Expand All @@ -356,6 +358,37 @@ public ReactionPaginationAction retrieveUsers()
return new ReactionPaginationActionImpl(this);
}

/**
* Retrieves the {@link net.dv8tion.jda.api.entities.User Users} that
* already reacted with this MessageReaction.
*
* <p>Possible ErrorResponses include:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>If the message this reaction was attached to got deleted.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>If the channel this reaction was used in got deleted.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>If we were removed from the channel/guild</li>
* </ul>
*
* @param type
* The specific type of reaction
*
* @return {@link ReactionPaginationAction ReactionPaginationAction}
*
* @see #retrieveUsers()
*/
@Nonnull
@CheckReturnValue
public ReactionPaginationAction retrieveUsers(@Nonnull ReactionType type)
{
Checks.notNull(type, "Type");
return new ReactionPaginationActionImpl(this, type);
}

/**
* Removes this Reaction from the Message.
* <br>This will remove our own reaction as an overload
Expand Down Expand Up @@ -511,6 +544,16 @@ public String toString()
*/
public enum ReactionType
{
NORMAL, SUPER
NORMAL(0), SUPER(1);

private final int value;
ReactionType(int type) {
this.value = type;
}

public int getValue()
{
return value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,20 @@ public class ReactionPaginationActionImpl
*/
public ReactionPaginationActionImpl(MessageReaction reaction)
{
super(reaction.getJDA(), Route.Messages.GET_REACTION_USERS.compile(reaction.getChannelId(), reaction.getMessageId(), getCode(reaction)), 1, 100, 100);
this(reaction, MessageReaction.ReactionType.NORMAL);
}

/**
* Creates a new PaginationAction instance
*
* @param reaction
* The target {@link net.dv8tion.jda.api.entities.MessageReaction MessageReaction}
* @param type
* Type of {@link net.dv8tion.jda.api.entities.MessageReaction.ReactionType MessageReaction.ReactionType} to retrieve users for
*/
public ReactionPaginationActionImpl(MessageReaction reaction, MessageReaction.ReactionType type)
{
super(reaction.getJDA(), Route.Messages.GET_REACTION_USERS.compile(reaction.getChannelId(), reaction.getMessageId(), getCode(reaction)).withQueryParams("type", String.valueOf(type.getValue())), 1, 100, 100);
super.order(PaginationOrder.FORWARD);
this.reaction = reaction;
}
Expand Down

0 comments on commit 5c2e60c

Please sign in to comment.