From 5c2e60cd2f44729488ecb1f2433eaa7384b8dc48 Mon Sep 17 00:00:00 2001 From: MTM123 Date: Mon, 30 Dec 2024 23:45:25 +0200 Subject: [PATCH] Add a way to retrieve users that used super reaction --- .../jda/api/entities/MessageReaction.java | 45 ++++++++++++++++++- .../ReactionPaginationActionImpl.java | 15 ++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/dv8tion/jda/api/entities/MessageReaction.java b/src/main/java/net/dv8tion/jda/api/entities/MessageReaction.java index 6ac7039479..41d40c26eb 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/MessageReaction.java +++ b/src/main/java/net/dv8tion/jda/api/entities/MessageReaction.java @@ -348,6 +348,8 @@ public long getMessageIdLong() * * * @return {@link ReactionPaginationAction ReactionPaginationAction} + * + * @see #retrieveUsers(ReactionType) */ @Nonnull @CheckReturnValue @@ -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. + * + *

Possible ErrorResponses include: + *

+ * + * @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. *
This will remove our own reaction as an overload @@ -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; + } } } diff --git a/src/main/java/net/dv8tion/jda/internal/requests/restaction/pagination/ReactionPaginationActionImpl.java b/src/main/java/net/dv8tion/jda/internal/requests/restaction/pagination/ReactionPaginationActionImpl.java index ea39c1a0b6..ac003012c8 100644 --- a/src/main/java/net/dv8tion/jda/internal/requests/restaction/pagination/ReactionPaginationActionImpl.java +++ b/src/main/java/net/dv8tion/jda/internal/requests/restaction/pagination/ReactionPaginationActionImpl.java @@ -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; }