diff --git a/src/main/java/net/dv8tion/jda/api/entities/Message.java b/src/main/java/net/dv8tion/jda/api/entities/Message.java index 427e57795f..b930d4d836 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/Message.java +++ b/src/main/java/net/dv8tion/jda/api/entities/Message.java @@ -1067,6 +1067,9 @@ default boolean isFromGuild() * or {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY} * in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} when adding the reaction. * + *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.
  • + * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} * The reaction request was attempted after the Message had been deleted.
  • * @@ -1100,7 +1103,7 @@ default boolean isFromGuild() /** * Adds a reaction to this Message using a unicode emoji. *
    A reference of unicode emojis can be found here: - * Emoji Table. + * Emoji Table. * *

    This message instance will not be updated by this operation. * @@ -1136,6 +1139,11 @@ default boolean isFromGuild() *
    The reaction request was attempted after the account lost {@link net.dv8tion.jda.api.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} * in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} when adding the reaction. * + *

  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided unicode character does not refer to a known emoji unicode character. + *
    Proper unicode characters for emojis can be found here: + * Emoji Table
  • + * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} * The reaction request was attempted after the Message had been deleted.
  • * @@ -1219,7 +1227,9 @@ default boolean isFromGuild() * or losing the {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL VIEW_CHANNEL} permission * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} - *
    The provided unicode emoji doesn't exist. Try using one of the example formats.
  • + *
    The provided unicode character does not refer to a known emoji unicode character. + *
    Proper unicode characters for emojis can be found here: + * Emoji Table * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
    The message was deleted.
  • @@ -1253,7 +1263,7 @@ default boolean isFromGuild() * or losing the {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL VIEW_CHANNEL} permission * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} - *
    The provided emote was deleted or doesn't exist.
  • + *
    The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel. * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
    The message was deleted.
  • @@ -1296,6 +1306,9 @@ default boolean isFromGuild() * due to {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked *
    Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY} * + *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.
  • + * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} * The reaction request was attempted after the Message had been deleted.
  • * @@ -1346,6 +1359,9 @@ default boolean isFromGuild() *
    The reaction request was attempted after the account lost {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} * in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} when removing the reaction. * + *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.
  • + * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} * The reaction request was attempted after the Message had been deleted.
  • * @@ -1367,6 +1383,8 @@ default boolean isFromGuild() *
  • If the provided {@link net.dv8tion.jda.api.entities.Emote Emote} cannot be used in the current channel. * See {@link Emote#canInteract(User, MessageChannel)} or {@link Emote#canInteract(Member)} for more information.
  • * + * @throws java.lang.IllegalStateException + * If the message was not sent in a TextChannel. * * @return {@link net.dv8tion.jda.api.requests.RestAction RestAction} - Type: {@link java.lang.Void} * @@ -1379,7 +1397,7 @@ default boolean isFromGuild() /** * Removes a reaction from this Message using a unicode emoji. *
    A reference of unicode emojis can be found here: - * Emoji Table. + * Emoji Table. * *

    This message instance will not be updated by this operation. * @@ -1405,6 +1423,11 @@ default boolean isFromGuild() * due to {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked *
    Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY} * + *

  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided unicode character does not refer to a known emoji unicode character. + *
    Proper unicode characters for emojis can be found here: + * Emoji Table
  • + * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} * The reaction request was attempted after the Message had been deleted.
  • * @@ -1431,7 +1454,7 @@ default boolean isFromGuild() /** * Removes a reaction from this Message using a unicode emoji. *
    A reference of unicode emojis can be found here: - * Emoji Table. + * Emoji Table. * *

    This message instance will not be updated by this operation. * @@ -1447,6 +1470,11 @@ default boolean isFromGuild() * due to {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked *
    Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY} * + *

  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided unicode character does not refer to a known emoji unicode character. + *
    Proper unicode characters for emojis can be found here: + * Emoji Table
  • + * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS} *
    The reaction request was attempted after the account lost {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} * in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} when removing the reaction.
  • @@ -1471,6 +1499,8 @@ default boolean isFromGuild() * * @throws java.lang.IllegalArgumentException * If the provided unicode emoji is null or empty. + * @throws java.lang.IllegalStateException + * If the message was not sent in a TextChannel. * * @return {@link net.dv8tion.jda.api.requests.RestAction RestAction} - Type: {@link java.lang.Void} * @@ -1495,6 +1525,9 @@ default boolean isFromGuild() * due to {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked *
    Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY} * + *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.
  • + * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} * The reaction request was attempted after the Message had been deleted.
  • * @@ -1533,6 +1566,11 @@ default boolean isFromGuild() * due to {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked *
    Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY} * + *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided unicode character does not refer to a known emoji unicode character. + *
    Proper unicode characters for emojis can be found here: + * Emoji Table
  • + * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} * The reaction request was attempted after the Message had been deleted.
  • * @@ -1564,26 +1602,11 @@ default boolean isFromGuild() *

    An instance of the related {@link net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote ReactionEmote} can be * obtained through this method by using the emoji's unicode value. * - * - *

    The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible: - *

    - * * @param unicode * The unicode value of the reaction emoji. * * @throws java.lang.UnsupportedOperationException * If this is not a Received Message from {@link net.dv8tion.jda.api.entities.MessageType#DEFAULT MessageType.DEFAULT} - * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException - * If the MessageChannel this message was sent in was a {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} and the - * logged in account does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY} in the channel. * @throws java.lang.IllegalArgumentException * If the provided unicode value is null or empty. * @@ -1601,28 +1624,13 @@ default boolean isFromGuild() *

    Messages store reactions by keeping a list of reaction names. * *

    An instance of the related {@link net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote ReactionEmote} can be - * obtained through this method by using the emoji's id. - * - * - *

    The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible: - *

    + * obtained through this method by using the emote's id. * * @param id - * The string id of the reaction emoji. + * The string id of the reaction emote. * * @throws java.lang.UnsupportedOperationException * If this is not a Received Message from {@link net.dv8tion.jda.api.entities.MessageType#DEFAULT MessageType.DEFAULT} - * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException - * If the MessageChannel this message was sent in was a {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} and the - * logged in account does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY} in the channel. * @throws java.lang.IllegalArgumentException * If the provided id is not a valid snowflake. * @@ -1640,30 +1648,13 @@ default boolean isFromGuild() *

    Messages store reactions by keeping a list of reaction names. * *

    An instance of the related {@link net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote ReactionEmote} can be - * obtained through this method by using the emoji's id. - * - * - *

    The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible: - *

    + * obtained through this method by using the emote's id. * * @param id - * The long id of the reaction emoji. + * The long id of the reaction emote. * * @throws java.lang.UnsupportedOperationException * If this is not a Received Message from {@link net.dv8tion.jda.api.entities.MessageType#DEFAULT MessageType.DEFAULT} - * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException - * If the MessageChannel this message was sent in was a {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} and the - * logged in account does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY} in the channel. - * @throws java.lang.IllegalArgumentException - * If the provided id is not a valid snowflake. * * @return The {@link net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote ReactionEmote} of this message or null if not present. * diff --git a/src/main/java/net/dv8tion/jda/api/entities/MessageChannel.java b/src/main/java/net/dv8tion/jda/api/entities/MessageChannel.java index 226f2a69f2..8cc5fd1e98 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/MessageChannel.java +++ b/src/main/java/net/dv8tion/jda/api/entities/MessageChannel.java @@ -23,6 +23,7 @@ import net.dv8tion.jda.api.requests.restaction.MessageAction; import net.dv8tion.jda.api.requests.restaction.pagination.MessagePaginationAction; import net.dv8tion.jda.api.requests.restaction.pagination.PaginationAction; +import net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction; import net.dv8tion.jda.api.utils.AttachmentOption; import net.dv8tion.jda.api.utils.MiscUtil; import net.dv8tion.jda.api.utils.data.DataArray; @@ -33,6 +34,7 @@ import net.dv8tion.jda.internal.requests.restaction.AuditableRestActionImpl; import net.dv8tion.jda.internal.requests.restaction.MessageActionImpl; import net.dv8tion.jda.internal.requests.restaction.pagination.MessagePaginationActionImpl; +import net.dv8tion.jda.internal.requests.restaction.pagination.ReactionPaginationActionImpl; import net.dv8tion.jda.internal.utils.Checks; import net.dv8tion.jda.internal.utils.EncodingUtil; @@ -1150,7 +1152,7 @@ default MessageHistory.MessageRetrieveAction getHistoryAround(@Nonnull String me @CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryAround(long messageId, int limit) { - return getHistoryAround(Long.toUnsignedString(messageId), limit ); + return getHistoryAround(Long.toUnsignedString(messageId), limit); } /** @@ -1705,8 +1707,8 @@ default RestAction sendTyping() * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} *
    The provided unicode character does not refer to a known emoji unicode character. - *
    Proper unicode characters for emojis can be found at - * http://unicode.org/emoji/charts/full-emoji-list.html
  • + *
    Proper unicode characters for emojis can be found here: + * Emoji Table * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
    The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or @@ -1723,7 +1725,7 @@ default RestAction sendTyping() * * @throws java.lang.IllegalArgumentException *
      - *
    • If provided {@code messageId} is {@code null} or empty.
    • + *
    • If provided {@code messageId} is {@code null} or not a valid snowflake.
    • *
    • If provided {@code unicode} is {@code null} or empty.
    • *
    * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException @@ -1790,8 +1792,8 @@ default RestAction addReactionById(@Nonnull String messageId, @Nonnull Str * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} *
    The provided unicode character does not refer to a known emoji unicode character. - *
    Proper unicode characters for emojis can be found at - * http://unicode.org/emoji/charts/full-emoji-list.html
  • + *
    Proper unicode characters for emojis can be found here: + * Emoji Table * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
    The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or @@ -1807,7 +1809,10 @@ default RestAction addReactionById(@Nonnull String messageId, @Nonnull Str * The unicode characters to react with * * @throws java.lang.IllegalArgumentException - * If provided {@code unicode} is {@code null} or empty. + *
      + *
    • If provided {@code messageId} is not a valid snowflake.
    • + *
    • If provided {@code unicode} is {@code null} or empty.
    • + *
    * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException * If the MessageChannel this message was sent in was a {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} * and the logged in account does not have: @@ -1848,10 +1853,8 @@ default RestAction addReactionById(long messageId, @Nonnull String unicode * {@link net.dv8tion.jda.api.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the * {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.
  • * - *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI} - *
    The provided unicode character does not refer to a known emoji unicode character. - *
    Proper unicode characters for emojis can be found at - * http://unicode.org/emoji/charts/full-emoji-list.html
  • + *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.
  • * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
    The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or @@ -1912,9 +1915,8 @@ default RestAction addReactionById(@Nonnull String messageId, @Nonnull Emo * {@link net.dv8tion.jda.api.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the * {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.
  • * - *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI} - *
    The request was attempted after the provided {@link net.dv8tion.jda.api.entities.Emote Emote} - * was deleted.
  • + *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.
  • * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
    The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or @@ -1931,7 +1933,7 @@ default RestAction addReactionById(@Nonnull String messageId, @Nonnull Emo * * @throws java.lang.IllegalArgumentException *
      - *
    • If provided {@code messageId} is not positive.
    • + *
    • If provided {@code messageId} is not a valid snowflake.
    • *
    • If provided {@code emote} is {@code null}
    • *
    * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException @@ -1978,10 +1980,10 @@ default RestAction addReactionById(long messageId, @Nonnull Emote emote) * {@link net.dv8tion.jda.api.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the * {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.
  • * - *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI} + *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} *
    The provided unicode character does not refer to a known emoji unicode character. - *
    Proper unicode characters for emojis can be found at - * http://unicode.org/emoji/charts/full-emoji-list.html
  • + *
    Proper unicode characters for emojis can be found here: + * Emoji Table * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
    The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or @@ -1998,7 +2000,7 @@ default RestAction addReactionById(long messageId, @Nonnull Emote emote) * * @throws java.lang.IllegalArgumentException *
      - *
    • If provided {@code messageId} is {@code null} or empty.
    • + *
    • If provided {@code messageId} is {@code null} or not a valid snowflake.
    • *
    • If provided {@code unicode} is {@code null} or empty.
    • *
    * @@ -2046,10 +2048,10 @@ default RestAction removeReactionById(@Nonnull String messageId, @Nonnull * {@link net.dv8tion.jda.api.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the * {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.
  • * - *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI} + *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} *
    The provided unicode character does not refer to a known emoji unicode character. - *
    Proper unicode characters for emojis can be found at - * http://unicode.org/emoji/charts/full-emoji-list.html
  • + *
    Proper unicode characters for emojis can be found here: + * Emoji Table * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
    The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or @@ -2066,7 +2068,7 @@ default RestAction removeReactionById(@Nonnull String messageId, @Nonnull * * @throws java.lang.IllegalArgumentException *
      - *
    • If provided {@code messageId} is {@code null} or empty.
    • + *
    • If provided {@code messageId} is not a valid snowflake.
    • *
    • If provided {@code unicode} is {@code null} or empty.
    • *
    * @@ -2100,10 +2102,8 @@ default RestAction removeReactionById(long messageId, @Nonnull String unic * {@link net.dv8tion.jda.api.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the * {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.
  • * - *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI} - *
    The provided unicode character does not refer to a known emoji unicode character. - *
    Proper unicode characters for emojis can be found at - * http://unicode.org/emoji/charts/full-emoji-list.html
  • + *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.
  • * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
    The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or @@ -2120,7 +2120,7 @@ default RestAction removeReactionById(long messageId, @Nonnull String unic * * @throws java.lang.IllegalArgumentException *
      - *
    • If provided {@code messageId} is {@code null} or empty.
    • + *
    • If provided {@code messageId} is {@code null} or not a valid snowflake.
    • *
    • If provided {@code emote} is {@code null}.
    • *
    * @@ -2155,10 +2155,8 @@ default RestAction removeReactionById(@Nonnull String messageId, @Nonnull * {@link net.dv8tion.jda.api.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the * {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.
  • * - *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI} - *
    The provided unicode character does not refer to a known emoji unicode character. - *
    Proper unicode characters for emojis can be found at - * http://unicode.org/emoji/charts/full-emoji-list.html
  • + *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
    The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.
  • * *
  • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
    The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or @@ -2175,7 +2173,7 @@ default RestAction removeReactionById(@Nonnull String messageId, @Nonnull * * @throws java.lang.IllegalArgumentException *
      - *
    • If provided {@code messageId} is {@code null} or empty.
    • + *
    • If provided {@code messageId} is not a valid snowflake.
    • *
    • If provided {@code emote} is {@code null}.
    • *
    * @@ -2188,6 +2186,211 @@ default RestAction removeReactionById(long messageId, @Nonnull Emote emote return removeReactionById(Long.toUnsignedString(messageId), emote); } + /** + * This obtains the {@link net.dv8tion.jda.api.entities.User users} who reacted to a message using the given unicode emoji. + * + *

    Messages maintain a list of reactions, alongside a list of users who added them. + * + *

    Using this data, we can obtain a {@link net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction ReactionPaginationAction} + * of the users who've reacted to this message. + * + *

    The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible: + *

      + *
    • {@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS} + *
      The retrieve request was attempted after the account lost access to the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} + * due to {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked + *
      Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}
    • + * + *
    • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
      The provided unicode character does not refer to a known emoji unicode character. + *
      Proper unicode characters for emojis can be found here: + * Emoji Table
    • + * + *
    • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} + *
      The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or + * the message it referred to has already been deleted.
    • + *
    + * + * + * @param messageId + * The messageId to retrieve the users from. + * @param unicode + * The unicode emote to retrieve users for. + * + * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException + * If this is a {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} and the + * logged in account does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}. + * @throws java.lang.IllegalArgumentException + *
      + *
    • If provided {@code messageId} is {@code null} or not a valid snowflake.
    • + *
    • If the provided unicode emoji is {@code null} or empty.
    • + *
    + * + * @return The {@link net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction ReactionPaginationAction} of the emoji's users. + * + * @since 4.2.0 + */ + @Nonnull + @CheckReturnValue + default ReactionPaginationAction retrieveReactionUsersById(@Nonnull String messageId, @Nonnull String unicode) + { + Checks.isSnowflake(messageId, "Message ID"); + Checks.notEmpty(unicode, "Emoji"); + Checks.noWhitespace(unicode, "Emoji"); + + return new ReactionPaginationActionImpl(this, messageId, EncodingUtil.encodeReaction(unicode)); + } + + /** + * This obtains the {@link net.dv8tion.jda.api.entities.User users} who reacted to a message using the given unicode emoji. + * + *

    Messages maintain a list of reactions, alongside a list of users who added them. + * + *

    Using this data, we can obtain a {@link net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction ReactionPaginationAction} + * of the users who've reacted to this message. + * + *

    The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible: + *

      + *
    • {@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS} + *
      The retrieve request was attempted after the account lost access to the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} + * due to {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked + *
      Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}
    • + * + *
    • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
      The provided unicode character does not refer to a known emoji unicode character. + *
      Proper unicode characters for emojis can be found here: + * Emoji Table
    • + * + *
    • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} + *
      The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or + * the message it referred to has already been deleted.
    • + *
    + * + * + * @param messageId + * The messageId to retrieve the users from. + * @param unicode + * The unicode emote to retrieve users for. + * + * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException + * If this is a {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} and the + * logged in account does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}. + * @throws java.lang.IllegalArgumentException + *
      + *
    • If provided {@code messageId} is not a valid snowflake.
    • + *
    • If provided unicode emoji is {@code null} or empty.
    • + *
    + * + * @return The {@link net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction ReactionPaginationAction} of the emoji's users. + * + * @since 4.2.0 + */ + @Nonnull + @CheckReturnValue + default ReactionPaginationAction retrieveReactionUsersById(long messageId, @Nonnull String unicode) + { + return retrieveReactionUsersById(Long.toUnsignedString(messageId), unicode); + } + + /** + * This obtains the {@link net.dv8tion.jda.api.entities.User users} who reacted to a message using the given {@link net.dv8tion.jda.api.entities.Emote emote}. + * + *

    Messages maintain a list of reactions, alongside a list of users who added them. + * + *

    Using this data, we can obtain a {@link net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction ReactionPaginationAction} + * of the users who've reacted to the given message. + * + *

    The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible: + *

      + *
    • {@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS} + *
      The retrieve request was attempted after the account lost access to the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} + * due to {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked + *
      Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}
    • + * + *
    • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
      The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.
    • + * + *
    • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} + *
      The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or + * the message it referred to has already been deleted.
    • + * + * @param messageId + * The messageId to retrieve the users from. + * @param emote + * The {@link net.dv8tion.jda.api.entities.Emote emote} to retrieve users for. + * + * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException + * If this is a {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} and the + * logged in account does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}. + * @throws java.lang.IllegalArgumentException + *
        + *
      • If provided {@code messageId} is {@code null} or not a valid snowflake.
      • + *
      • If provided {@link net.dv8tion.jda.api.entities.Emote Emote} is {@code null}.
      • + *
      + * + * @return The {@link net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction ReactionPaginationAction} of the emote's users. + * + * @since 4.2.0 + */ + @Nonnull + @CheckReturnValue + default ReactionPaginationAction retrieveReactionUsersById(@Nonnull String messageId, @Nonnull Emote emote) + { + Checks.isSnowflake(messageId, "Message ID"); + Checks.notNull(emote, "Emote"); + + return new ReactionPaginationActionImpl(this, messageId, String.format("%s:%s", emote, emote.getId())); + } + + /** + * This obtains the {@link net.dv8tion.jda.api.entities.User users} who reacted to a message using the given {@link net.dv8tion.jda.api.entities.Emote emote}. + * + *

      Messages maintain a list of reactions, alongside a list of users who added them. + * + *

      Using this data, we can obtain a {@link net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction ReactionPaginationAction} + * of the users who've reacted to the given message. + * + *

      The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible: + *

        + *
      • {@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS} + *
        The retrieve request was attempted after the account lost access to the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} + * due to {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked + *
        Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}
      • + * + *
      • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} + *
        The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.
      • + * + *
      • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} + *
        The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or + * the message it referred to has already been deleted.
      • + * + * @param messageId + * The messageId to retrieve the users from. + * @param emote + * The {@link net.dv8tion.jda.api.entities.Emote emote} to retrieve users for. + * + * @throws java.lang.UnsupportedOperationException + * If this is not a Received Message from {@link net.dv8tion.jda.api.entities.MessageType#DEFAULT MessageType.DEFAULT} + * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException + * If this is a {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} and the + * logged in account does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}. + * @throws java.lang.IllegalArgumentException + *
          + *
        • If provided {@code messageId} is not a valid snowflake.
        • + *
        • If provided {@link net.dv8tion.jda.api.entities.Emote Emote} is {@code null}.
        • + *
        + * + * @return The {@link net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction ReactionPaginationAction} of the emote's users. + * + * @since 4.2.0 + */ + @Nonnull + @CheckReturnValue + default ReactionPaginationAction retrieveReactionUsersById(long messageId, @Nonnull Emote emote) + { + return retrieveReactionUsersById(Long.toUnsignedString(messageId), emote); + } + /** * Used to pin a message. Pinned messages are retrievable via {@link #retrievePinnedMessages()}. * @@ -2232,7 +2435,7 @@ default RestAction pinMessageById(@Nonnull String messageId) Checks.isSnowflake(messageId, "Message ID"); Route.CompiledRoute route = Route.Messages.ADD_PINNED_MESSAGE.compile(getId(), messageId); - return new RestActionImpl(getJDA(), route); + return new RestActionImpl<>(getJDA(), route); } /** @@ -2262,7 +2465,7 @@ default RestAction pinMessageById(@Nonnull String messageId) * The message to pin. * * @throws IllegalArgumentException - * if the provided messageId is not positive. + * if the provided {@code messageId} is not a valid snowflake. * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException * If this is a {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} and the logged in account does not have *
          diff --git a/src/main/java/net/dv8tion/jda/api/entities/TextChannel.java b/src/main/java/net/dv8tion/jda/api/entities/TextChannel.java index 3e2288c995..3219e0421f 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/TextChannel.java +++ b/src/main/java/net/dv8tion/jda/api/entities/TextChannel.java @@ -543,8 +543,8 @@ default RestAction clearReactionsById(long messageId, @Nonnull Emote emote * *
        • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI} *
          The provided unicode character does not refer to a known emoji unicode character. - *
          Proper unicode characters for emojis can be found at - * http://unicode.org/emoji/charts/full-emoji-list.html
        • + *
          Proper unicode characters for emojis can be found here: + * Emoji Table * *
        • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
          The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or @@ -606,8 +606,8 @@ default RestAction clearReactionsById(long messageId, @Nonnull Emote emote * *
        • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI} *
          The provided unicode character does not refer to a known emoji unicode character. - *
          Proper unicode characters for emojis can be found at - * http://unicode.org/emoji/charts/full-emoji-list.html
        • + *
          Proper unicode characters for emojis can be found here: + * Emoji Table * *
        • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
          The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or @@ -666,8 +666,8 @@ default RestAction removeReactionById(long messageId, @Nonnull String unic * *
        • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI} *
          The provided unicode character does not refer to a known emoji unicode character. - *
          Proper unicode characters for emojis can be found at - * http://unicode.org/emoji/charts/full-emoji-list.html
        • + *
          Proper unicode characters for emojis can be found here: + * Emoji Table * *
        • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
          The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or @@ -727,8 +727,8 @@ default RestAction removeReactionById(@Nonnull String messageId, @Nonnull * *
        • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI} *
          The provided unicode character does not refer to a known emoji unicode character. - *
          Proper unicode characters for emojis can be found at - * http://unicode.org/emoji/charts/full-emoji-list.html
        • + *
          Proper unicode characters for emojis can be found here: + * Emoji Table * *
        • {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} *
          The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or diff --git a/src/main/java/net/dv8tion/jda/api/requests/restaction/pagination/ReactionPaginationAction.java b/src/main/java/net/dv8tion/jda/api/requests/restaction/pagination/ReactionPaginationAction.java index de6f28a8ea..5b7ab1eb76 100644 --- a/src/main/java/net/dv8tion/jda/api/requests/restaction/pagination/ReactionPaginationAction.java +++ b/src/main/java/net/dv8tion/jda/api/requests/restaction/pagination/ReactionPaginationAction.java @@ -16,10 +16,7 @@ package net.dv8tion.jda.api.requests.restaction.pagination; -import net.dv8tion.jda.api.entities.Emote; -import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.MessageReaction; -import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.entities.*; import javax.annotation.Nonnull; @@ -53,6 +50,10 @@ * @see MessageReaction#retrieveUsers() * @see Message#retrieveReactionUsers(String) * @see Message#retrieveReactionUsers(Emote) + * @see MessageChannel#retrieveReactionUsersById(long, Emote) + * @see MessageChannel#retrieveReactionUsersById(String, Emote) + * @see MessageChannel#retrieveReactionUsersById(long, String) + * @see MessageChannel#retrieveReactionUsersById(String, String) */ public interface ReactionPaginationAction extends PaginationAction { @@ -60,7 +61,7 @@ public interface ReactionPaginationAction extends PaginationAction removeReaction(@Nonnull String unicode, @Nonnull User us return getTextChannel().removeReactionById(getId(), unicode, user); } - @Nonnull @Override public ReactionPaginationAction retrieveReactionUsers(@Nonnull Emote emote) { - Checks.notNull(emote, "Emote"); - - MessageReaction reaction = this.reactions.stream() - .filter(r -> r.getReactionEmote().isEmote() && r.getReactionEmote().getEmote().equals(emote)) - .findFirst().orElse(null); - - if (reaction == null) - return new ReactionPaginationActionImpl(this, String.format("%s:%s", emote, emote.getId())); - return new ReactionPaginationActionImpl(reaction); + return channel.retrieveReactionUsersById(id, emote); } @Nonnull @Override public ReactionPaginationAction retrieveReactionUsers(@Nonnull String unicode) { - Checks.noWhitespace(unicode, "Emoji"); - - MessageReaction reaction = this.reactions.stream() - .filter(r -> r.getReactionEmote().isEmoji() && r.getReactionEmote().getEmoji().equals(unicode)) - .findFirst().orElse(null); - - if (reaction == null) - return new ReactionPaginationActionImpl(this, EncodingUtil.encodeUTF8(unicode)); - return new ReactionPaginationActionImpl(reaction); + return channel.retrieveReactionUsersById(id, unicode); } @Override public MessageReaction.ReactionEmote getReactionByUnicode(@Nonnull String unicode) { + Checks.notEmpty(unicode, "Emoji"); Checks.noWhitespace(unicode, "Emoji"); return this.reactions.stream() @@ -261,8 +243,6 @@ public MessageReaction.ReactionEmote getReactionById(@Nonnull String id) @Override public MessageReaction.ReactionEmote getReactionById(long id) { - Checks.notNull(id, "Reaction ID"); - return this.reactions.stream() .map(MessageReaction::getReactionEmote) .filter(r -> r.isEmote() && r.getIdLong() == id) diff --git a/src/main/java/net/dv8tion/jda/internal/entities/TextChannelImpl.java b/src/main/java/net/dv8tion/jda/internal/entities/TextChannelImpl.java index 35439e49c6..717abcbe84 100644 --- a/src/main/java/net/dv8tion/jda/internal/entities/TextChannelImpl.java +++ b/src/main/java/net/dv8tion/jda/internal/entities/TextChannelImpl.java @@ -25,6 +25,7 @@ import net.dv8tion.jda.api.requests.restaction.ChannelAction; import net.dv8tion.jda.api.requests.restaction.MessageAction; import net.dv8tion.jda.api.requests.restaction.WebhookAction; +import net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction; import net.dv8tion.jda.api.utils.AttachmentOption; import net.dv8tion.jda.api.utils.MiscUtil; import net.dv8tion.jda.api.utils.TimeUtil; @@ -35,6 +36,7 @@ import net.dv8tion.jda.internal.requests.Route; import net.dv8tion.jda.internal.requests.restaction.AuditableRestActionImpl; import net.dv8tion.jda.internal.requests.restaction.WebhookActionImpl; +import net.dv8tion.jda.internal.requests.restaction.pagination.ReactionPaginationActionImpl; import net.dv8tion.jda.internal.utils.Checks; import net.dv8tion.jda.internal.utils.EncodingUtil; @@ -500,6 +502,31 @@ public RestActionImpl removeReactionById(@Nonnull String messageId, @Nonnu return new RestActionImpl<>(getJDA(), route); } + @Nonnull + @Override + public ReactionPaginationAction retrieveReactionUsersById(@Nonnull String messageId, @Nonnull String unicode) + { + Checks.isSnowflake(messageId, "Message ID"); + Checks.notEmpty(unicode, "Emoji"); + Checks.noWhitespace(unicode, "Emoji"); + + checkPermission(Permission.MESSAGE_HISTORY); + + return new ReactionPaginationActionImpl(this, messageId, EncodingUtil.encodeUTF8(unicode)); + } + + @Nonnull + @Override + public ReactionPaginationAction retrieveReactionUsersById(@Nonnull String messageId, @Nonnull Emote emote) + { + Checks.isSnowflake(messageId, "Message ID"); + Checks.notNull(emote, "Emote"); + + checkPermission(Permission.MESSAGE_HISTORY); + + return new ReactionPaginationActionImpl(this, messageId, String.format("%s:%s", emote, emote.getId())); + } + @Nonnull @Override public MessageAction editMessageById(@Nonnull String messageId, @Nonnull CharSequence newContent) 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 a96b5b78d9..a6e3656f31 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 @@ -17,6 +17,7 @@ package net.dv8tion.jda.internal.requests.restaction.pagination; import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.entities.MessageChannel; import net.dv8tion.jda.api.entities.MessageReaction; import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.exceptions.ParsingException; @@ -56,6 +57,12 @@ public ReactionPaginationActionImpl(Message message, String code) this.reaction = null; } + public ReactionPaginationActionImpl(MessageChannel channel, String messageId, String code) + { + super(channel.getJDA(), Route.Messages.GET_REACTION_USERS.compile(channel.getId(), messageId, code), 1, 100, 100); + this.reaction = null; + } + protected static String getCode(MessageReaction reaction) { MessageReaction.ReactionEmote emote = reaction.getReactionEmote();