Class RestMessage

java.lang.Object
discord4j.rest.entity.RestMessage

public class RestMessage extends Object
Represents a message within Discord.
  • Method Details

    • create

      public static RestMessage create(RestClient restClient, Snowflake channelId, Snowflake id)
      Create a RestMessage with the given parameters. This method does not perform any API request.
      Parameters:
      restClient - REST API resources
      channelId - the ID of the channel this messages belongs to
      id - the ID of this message
      Returns:
      a RestMessage represented by the given parameters.
    • getChannelId

      public Snowflake getChannelId()
      Returns the ID of the channel this message belongs to.
      Returns:
      The ID of the channel this message belongs to
    • getId

      public Snowflake getId()
      Returns the ID of this message.
      Returns:
      The ID of this message
    • channel

      public RestChannel channel()
    • getData

      public Mono<discord4j.discordjson.json.MessageData> getData()
      Retrieve this messages' data upon subscription.
      Returns:
      a Mono where, upon successful completion, emits the MessageData belonging to this channel. If an error is received, it is emitted through the Mono.
      See Also:
    • createReaction

      public Mono<Void> createReaction(String emoji)
      Requests to add a reaction on this message.
      Parameters:
      emoji - The reaction to add on this message. emoji takes the form of name:id for custom guild emoji, or Unicode characters.
      Returns:
      A Mono where, upon successful completion, emits nothing; indicating the reaction was added on this message. If an error is received, it is emitted through the Mono.
      See Also:
    • deleteOwnReaction

      public Mono<Void> deleteOwnReaction(String emoji)
      Requests to remove a reaction from the current user on this message.
      Parameters:
      emoji - The reaction to remove on this message.
      Returns:
      A Mono where, upon successful completion, emits nothing; indicating the reaction from the current user was removed on this message. If an error is received, it is emitted through the Mono.
      See Also:
    • deleteUserReaction

      public Mono<Void> deleteUserReaction(String emoji, Snowflake userId)
      Requests to remove a reaction from a specified user on this message.
      Parameters:
      emoji - The reaction to remove on this message.
      userId - The user to remove the reaction on this message.
      Returns:
      A Mono where, upon successful completion, emits nothing; indicating the reaction from the specified user was removed on this message. If an error is received, it is emitted through the Mono.
      See Also:
    • deleteAllReactions

      public Mono<Void> deleteAllReactions()
      Requests to remove all the reactions on this message.
      Returns:
      A Mono where, upon successful completion, emits nothing; indicating all the reactions on this message were removed. If an error is received, it is emitted through the Mono.
      See Also:
    • deleteReactions

      public Mono<Void> deleteReactions(String emoji)
      Requests to remove a specified reaction on this message.
      Parameters:
      emoji - The reaction to remove on this message.
      Returns:
      A Mono where, upon successful completion, emits nothing; indicating the reaction from the specified user was removed on this message. If an error is received, it is emitted through the Mono.
      See Also:
    • edit

      public Mono<discord4j.discordjson.json.MessageData> edit(discord4j.discordjson.json.MessageEditRequest request)
      Requests to edit this message.
      Parameters:
      request - The request body used to create a new message.
      Returns:
      A Mono where, upon successful completion, emits the edited MessageData. If an error is received, it is emitted through the Mono.
      See Also:
    • delete

      public Mono<Void> delete(@Nullable String reason)
      Requests to delete this message while optionally specifying a reason.
      Parameters:
      reason - The reason, if present.
      Returns:
      A Mono where, upon successful completion, emits nothing; indicating the message has been deleted. If an error is received, it is emitted through the Mono.
      See Also:
    • publish

      public Mono<discord4j.discordjson.json.MessageData> publish()
      Requests to publish (crosspost) this message if the channel is of type 'news'. Requires 'SEND_MESSAGES' permission if the current user sent the message, or additionally the 'MANAGE_MESSAGES' permission, for all other messages, to be present for the current user.
      Returns:
      A Mono where, upon successful completion, emits the published MessageData (crossposted) in the guilds. If an error is received, it is emitted through the Mono.
      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object