Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to retrieve users that used super reaction #2786

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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