Class Message

    • Field Detail

      • MAX_CONTENT_LENGTH

        public static final int MAX_CONTENT_LENGTH
        The maximum amount of characters that can be in the contents of a message.
        See Also:
        Constant Field Values
      • MAX_TOTAL_EMBEDS_CHARACTER_LENGTH

        public static final int MAX_TOTAL_EMBEDS_CHARACTER_LENGTH
        The maximum amount of characters that can be present when combining all title, description, field.name, field.value, footer.text, and author.name fields of all embeds for this message.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Message

        public Message​(GatewayDiscordClient gateway,
                       discord4j.discordjson.json.MessageData data)
        Constructs a Message with an associated GatewayDiscordClient and Discord data.
        Parameters:
        gateway - The GatewayDiscordClient associated to this object, must be non-null.
        data - The raw data as represented by Discord, must be non-null.
    • Method Detail

      • getId

        public Snowflake getId()
        Description copied from interface: Entity
        Gets the Snowflake that uniquely identifies this entity.
        Specified by:
        getId in interface Entity
        Returns:
        The Snowflake that uniquely identifies this entity.
      • getData

        public discord4j.discordjson.json.MessageData getData()
        Gets the data of the message.
        Returns:
        The data of the message.
      • getRestMessage

        public RestMessage getRestMessage()
        Returns:
        A RestMessage handle to execute REST API operations on this entity.
      • getRestChannel

        public RestChannel getRestChannel()
        Returns:
        A RestChannel handle to execute REST API operations on the channel of this message.
      • getChannelId

        public Snowflake getChannelId()
        Gets the ID of the channel the message was sent in.
        Returns:
        The ID of the channel the message was sent in.
      • getChannel

        public Mono<MessageChannel> getChannel()
        Requests to retrieve the channel the message was sent in.
        Returns:
        A Mono where, upon successful completion, emits the channel the message was sent in. If an error is received, it is emitted through the Mono.
      • getChannel

        public Mono<MessageChannel> getChannel​(EntityRetrievalStrategy retrievalStrategy)
        Requests to retrieve the channel the message was sent in, using the given retrieval strategy.
        Parameters:
        retrievalStrategy - the strategy to use to get the channel
        Returns:
        A Mono where, upon successful completion, emits the channel the message was sent in. If an error is received, it is emitted through the Mono.
      • getWebhookId

        public Optional<Snowflake> getWebhookId()
        Gets the ID the webhook that generated this message, if present.
        Returns:
        The ID of the webhook that generated this message, if present.
      • getAuthor

        public Optional<User> getAuthor()
        Gets the author of this message, if present.
        Returns:
        The author of this message, if present.
      • getAuthorAsMember

        public Mono<Member> getAuthorAsMember()
        Requests to retrieve the author of this message as a member of the guild in which it was sent.
        Returns:
        A Mono where, upon successful completion, emits the author of this message as a member of the guild in which it was sent, if present. If an error is received, it is emitted through the Mono.
      • getUserData

        @Experimental
        public discord4j.discordjson.json.UserData getUserData()
        Gets the raw author data of this message.
        Returns:
        The raw author data of this message.
      • getContent

        public String getContent()
        Gets the contents of the message, if present.
        Returns:
        The contents of the message, if present.
      • getTimestamp

        public Instant getTimestamp()
        Gets when this message was sent.
        Returns:
        When this message was sent.
      • getEditedTimestamp

        public Optional<Instant> getEditedTimestamp()
        Gets when this message was edited, if present.
        Returns:
        When this message was edited, if present.
      • isTts

        public boolean isTts()
        Gets whether this was a TTS (Text-To-Speech) message.
        Returns:
        true if this message was a TTS (Text-To-Speech) message, false otherwise.
      • mentionsEveryone

        public boolean mentionsEveryone()
        Gets whether this message mentions everyone.
        Returns:
        true if this message mentions everyone, false otherwise.
      • getUserMentionIds

        public List<Snowflake> getUserMentionIds()
        Gets the IDs of the users specifically mentioned in this message, without duplication and with the same order as in the message.
        Returns:
        The IDs of the users specifically mentioned in this message, without duplication and with the same order as in the message.
      • getMemberMentions

        public List<PartialMember> getMemberMentions()
        Gets the partial members specifically mentioned in this message, without duplication and with the same order as in the message.
        Returns:
        The partial members specifically mentioned in this message, without duplication and with the same order as in the message.
      • getUserMentions

        public List<User> getUserMentions()
        Gets the users specifically mentioned in this message, without duplication and with the same order as in the message.
        Returns:
        The users specifically mentioned in this message, without duplication and with the same order as in the message.
      • getRoleMentionIds

        public List<Snowflake> getRoleMentionIds()
        Gets the IDs of the roles specifically mentioned in this message, without duplication and with the same order as in the message.
        Returns:
        The IDs of the roles specifically mentioned in this message, without duplication and with the same order as in the message.
      • getRoleMentions

        public Flux<Role> getRoleMentions()
        Requests to retrieve the roles specifically mentioned in this message.
        Returns:
        A Flux that continually emits roles specifically mentioned in this message. If an error is received, it is emitted through the Flux.
      • getRoleMentions

        public Flux<Role> getRoleMentions​(EntityRetrievalStrategy retrievalStrategy)
        Requests to retrieve the roles specifically mentioned in this message, using the given retrieval strategy.
        Parameters:
        retrievalStrategy - the strategy to use to get the roles
        Returns:
        A Flux that continually emits roles specifically mentioned in this message. If an error is received, it is emitted through the Flux.
      • getAttachments

        public List<Attachment> getAttachments()
        Gets any attached files, with the same order as in the message.
        Returns:
        Any attached files, with the same order as in the message.
      • getEmbeds

        public List<Embed> getEmbeds()
        Gets any embedded content.
        Returns:
        Any embedded content.
      • getReactions

        public List<Reaction> getReactions()
        Gets the reactions to this message, the order is the same as in the message.
        Returns:
        The reactions to this message, the order is the same as in the message.
      • getReactors

        public Flux<User> getReactors​(ReactionEmoji emoji)
        Requests to retrieve the reactors (users) for the specified emoji for this message.
        Parameters:
        emoji - The emoji to get the reactors (users) for this message.
        Returns:
        A Flux that continually emits the reactors for the specified emoji for this message. If an error is received, it is emitted through the Flux.
      • isPinned

        public boolean isPinned()
        Gets whether this message is pinned.
        Returns:
        true if this message is pinned, false otherwise.
      • getWebhook

        public Mono<Webhook> getWebhook()
        Requests to retrieve the webhook that generated this message, if present.
        Returns:
        A Mono where, upon successful completion, emits the webhook that generated this message, if present. If an error is received, it is emitted through the Mono.
      • getFlags

        public EnumSet<Message.Flag> getFlags()
        Returns the flags of this Message, describing its features.
        Returns:
        A EnumSet with the flags of this message.
      • getGuildId

        public Optional<Snowflake> getGuildId()
        Gets the ID of the guild this message is associated to, if this Message was built from Gateway data, like an incoming event. If requested from REST API, this field will be empty.
        Returns:
        The ID of the guild this message is associated to, if present.
      • getGuild

        public Mono<Guild> getGuild()
        Requests to retrieve the guild this message is associated to, if present.
        Returns:
        A Mono where, upon successful completion, emits the Guild this message is associated to, if present. If an error is received, it is emitted through the Mono.
      • getGuild

        public Mono<Guild> getGuild​(EntityRetrievalStrategy retrievalStrategy)
        Requests to retrieve the guild this message is associated to, if present, using the given retrieval strategy.
        Parameters:
        retrievalStrategy - the strategy to use to get the guild
        Returns:
        A Mono where, upon successful completion, emits the Guild this message is associated to, if present. If an error is received, it is emitted through the Mono.
      • getType

        public Message.Type getType()
        Gets the type of message.
        Returns:
        The type of message.
      • getStickers

        public List<Sticker> getStickers()
        Gets the stickers sent with the message.
        Returns:
        The stickers sent with the message.
      • getComponents

        public List<LayoutComponent> getComponents()
        Gets the components on the message.
        Returns:
        The components on the message.
      • edit

        public Mono<Message> edit​(discord4j.core.spec.MessageEditSpec spec)
        Requests to edit this message.
        Parameters:
        spec - an immutable object that specifies how to edit the message
        Returns:
        A Mono where, upon successful completion, emits the edited Message. If an error is received, it is emitted through the Mono.
      • edit

        public discord4j.core.spec.MessageEditMono edit()
        Requests to edit this message. Properties specifying how to edit this message can be set via the withXxx methods of the returned MessageEditMono.
        Returns:
        A MessageEditMono where, upon successful completion, emits the edited Message. If an error is received, it is emitted through the MessageEditMono.
        See Also:
        edit(MessageEditSpec)
      • delete

        public Mono<Void> delete()
        Requests to delete this message.
        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.
      • 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.
      • suppressEmbeds

        @Experimental
        public Mono<Void> suppressEmbeds​(boolean suppress)
        Requests to suppress all embeds in this message. If the message have the embeds suppressed then this action can undo the suppressed embeds.
        Parameters:
        suppress - Determine if you need suppress or not the embeds.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the process has been completed. If an error is received, it is emitted through the Mono.
      • addReaction

        public Mono<Void> addReaction​(ReactionEmoji emoji)
        Requests to add a reaction on this message.
        Parameters:
        emoji - The reaction to add on this message.
        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.
      • removeReaction

        public Mono<Void> removeReaction​(ReactionEmoji 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.
      • removeReactions

        public Mono<Void> removeReactions​(ReactionEmoji emoji)
        Requests to remove all reactions of a specific emoji 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.
      • removeSelfReaction

        public Mono<Void> removeSelfReaction​(ReactionEmoji 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.
      • removeAllReactions

        public Mono<Void> removeAllReactions()
        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.
      • pin

        public Mono<Void> pin()
        Requests to pin this message.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the messaged was pinned. If an error is received, it is emitted through the Mono.
      • unpin

        public Mono<Void> unpin()
        Requests to unpin this message.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the message was unpinned. If an error is received, it is emitted through the Mono.
      • publish

        public Mono<Message> 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 Message in the guilds. If an error is received, it is emitted through the Mono.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object