Interface Message

    • Field Detail

      • MAX_CONTENT_LENGTH

        static final int MAX_CONTENT_LENGTH
        The maximum amount of characters sendable in one message. (2000)
        This only applies to the raw content and not embeds!
        See Also:
        MessageAction.append(...), Constant Field Values
      • INVITE_PATTERN

        static final java.util.regex.Pattern INVITE_PATTERN
        Pattern used to find instant invites in strings.

        The only named group is at index 1 with the name "code".

        See Also:
        getInvites()
      • JUMP_URL_PATTERN

        static final java.util.regex.Pattern JUMP_URL_PATTERN
        Pattern used to find Jump URLs in strings.

        Groups

        Javadoc is stupid, this is not a required tag
        Index Name Description
        0 N/A The entire link
        1 guild The ID of the target guild
        2 channel The ID of the target channel
        3 message The ID of the target message
        You can use the names with Matcher.group(String) and the index with Matcher.group(int).
        See Also:
        getJumpUrl()
    • Method Detail

      • getMessageReference

        @Nullable
        MessageReference getMessageReference()
        Returns the MessageReference for this Message. This will be null if this Message has no reference.

        You can access all the information about a reference through this object. Additionally, you can retrieve the referenced Message if discord did not load it in time. This can be done with MessageReference.resolve().

        Returns:
        The message reference, or null.
      • getReferencedMessage

        @Nullable
        default Message getReferencedMessage()
        Referenced message.

        This will have different meaning depending on the type of message. Usually, this is a INLINE_REPLY reference. This can be null even if the type is INLINE_REPLY, when the message it references doesn't exist or discord wasn't able to resolve it in time.

        This differs from a MessageReference, which contains the raw IDs attached to the reference, and allows you to retrieve the referenced message

        Returns:
        The referenced message, or null
        See Also:
        getMessageReference()
      • getMentionedUsers

        @Nonnull
        java.util.List<User> getMentionedUsers()
        An immutable list of all mentioned Users.
        If no user was mentioned, this list is empty. Elements are sorted in order of appearance. This only counts direct mentions of the user and not mentions through roles or the everyone tag.
        Returns:
        immutable list of mentioned users
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getMentionedUsersBag

        @Nonnull
        org.apache.commons.collections4.Bag<User> getMentionedUsersBag()
        A Bag of mentioned users.
        This can be used to retrieve the amount of times a user was mentioned in this message. This only counts direct mentions of the user and not mentions through roles or the everyone tag.

        Example

        
         public void sendCount(Message msg)
         {
             List<User> mentions = msg.getMentionedUsers(); // distinct list, in order of appearance
             Bag<User> count = msg.getMentionedUsersBag();
             StringBuilder content = new StringBuilder();
             for (User user : mentions)
             {
                 content.append(user.getAsTag())
                        .append(": ")
                        .append(count.getCount(user))
                        .append("\n");
             }
             msg.getChannel().sendMessage(content.toString()).queue();
         }
         
        Returns:
        Bag of mentioned users
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        See Also:
        getMentionedUsers()
      • getMentionedChannels

        @Nonnull
        java.util.List<TextChannel> getMentionedChannels()
        A immutable list of all mentioned TextChannels.
        If none were mentioned, this list is empty. Elements are sorted in order of appearance.

        This may include TextChannels from other Guilds

        Returns:
        immutable list of mentioned TextChannels
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getMentionedChannelsBag

        @Nonnull
        org.apache.commons.collections4.Bag<TextChannel> getMentionedChannelsBag()
        A Bag of mentioned channels.
        This can be used to retrieve the amount of times a channel was mentioned in this message.

        Example

        
         public void sendCount(Message msg)
         {
             List<TextChannel> mentions = msg.getMentionedTextChannels(); // distinct list, in order of appearance
             Bag<TextChannel> count = msg.getMentionedTextChannelsBag();
             StringBuilder content = new StringBuilder();
             for (TextChannel channel : mentions)
             {
                 content.append("#")
                        .append(channel.getName())
                        .append(": ")
                        .append(count.getCount(channel))
                        .append("\n");
             }
             msg.getChannel().sendMessage(content.toString()).queue();
         }
         
        Returns:
        Bag of mentioned channels
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        See Also:
        getMentionedChannels()
      • getMentionedRoles

        @Nonnull
        java.util.List<Role> getMentionedRoles()
        A immutable list of all mentioned Roles.
        If none were mentioned, this list is empty. Elements are sorted in order of appearance. This only counts direct mentions of the role and not mentions through the everyone tag.

        This may include Roles from other Guilds

        Returns:
        immutable list of mentioned Roles
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getMentionedRolesBag

        @Nonnull
        org.apache.commons.collections4.Bag<Role> getMentionedRolesBag()
        A Bag of mentioned roles.
        This can be used to retrieve the amount of times a role was mentioned in this message. This only counts direct mentions of the role and not mentions through the everyone tag. If a role is not mentionable it will not be included.

        Example

        
         public void sendCount(Message msg)
         {
             List<Role> mentions = msg.getMentionedRoles(); // distinct list, in order of appearance
             Bag<Role> count = msg.getMentionedRolesBag();
             StringBuilder content = new StringBuilder();
             for (Role role : mentions)
             {
                 content.append(role.getName())
                        .append(": ")
                        .append(count.getCount(role))
                        .append("\n");
             }
             msg.getChannel().sendMessage(content.toString()).queue();
         }
         
        Returns:
        Bag of mentioned roles
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        See Also:
        getMentionedRoles()
      • getMentionedMembers

        @Nonnull
        java.util.List<Member> getMentionedMembers​(@Nonnull
                                                   Guild guild)
        Creates an immutable list of Members representing the users of getMentionedUsers() in the specified Guild.
        This is only a convenience method and will skip all users that are not in the specified Guild.
        Parameters:
        guild - Non-null Guild that will be used to retrieve Members.
        Returns:
        Immutable list of mentioned Members
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        java.lang.IllegalArgumentException - If the specified Guild is null
        Since:
        3.4.0
      • getMentionedMembers

        @Nonnull
        java.util.List<Member> getMentionedMembers()
        Creates an immutable list of Members representing the users of getMentionedUsers() in the Guild this Message was sent in.
        This is only a convenience method and will skip all users that are not in the specified Guild.
        It will provide the getGuild() output Guild to getMentionedMembers(Guild).
        Returns:
        Immutable list of mentioned Members
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        java.lang.IllegalStateException - If this message was not sent in a TextChannel
        Since:
        3.4.0
      • getMentions

        @Nonnull
        java.util.List<IMentionable> getMentions​(@Nonnull
                                                 Message.MentionType... types)
        Combines all instances of IMentionable filtered by the specified MentionType values.
        This does not include getMentionedMembers() to avoid duplicates.

        If no MentionType values are given this will fallback to all types.

        Parameters:
        types - Amount of MentionTypes to include in the list of mentions
        Returns:
        Immutable list of filtered IMentionable instances
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        java.lang.IllegalArgumentException - If provided with null
        Since:
        3.4.0
      • isMentioned

        boolean isMentioned​(@Nonnull
                            IMentionable mentionable,
                            @Nonnull
                            Message.MentionType... types)
        Checks if given IMentionable was mentioned in this message in any way (@User, @everyone, @here, @Role).
        If no filtering MentionTypes are specified this will fallback to all mention types.

        MentionType.HERE and MentionType.EVERYONE will only be checked, if the given IMentionable is of type User or Member.
        Online status of Users/Members is NOT considered when checking MentionType.HERE.

        Parameters:
        mentionable - The mentionable entity to check on.
        types - The types to include when checking whether this type was mentioned. This will be used with getMentions(MentionType...)
        Returns:
        True, if the given mentionable was mentioned in this message
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • mentionsEveryone

        boolean mentionsEveryone()
        Indicates if this Message mentions everyone using @everyone or @here.
        Returns:
        True, if message is mentioning everyone
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • isEdited

        boolean isEdited()
        Returns whether or not this Message has been edited before.
        Returns:
        True if this message has been edited.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getTimeEdited

        @Nullable
        java.time.OffsetDateTime getTimeEdited()
        Provides the OffsetDateTime defining when this Message was last edited. If this Message has not been edited (isEdited() is false), then this method will return null.
        Returns:
        Time of the most recent edit, or null if the Message has never been edited.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getAuthor

        @Nonnull
        User getAuthor()
        The author of this Message
        Returns:
        Message author
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getMember

        @Nullable
        Member getMember()
        Returns the author of this Message as a member.
        This is only valid if the Message was actually sent in a TextChannel. This will return null if the message was not sent in a TextChannel, or if the message was sent by a Webhook.
        You can check the type of channel this message was sent from using isFromType(ChannelType) or getChannelType().

        Discord does not provide a member object for messages returned by RestActions of any kind. This will return null if the message was retrieved through MessageChannel.retrieveMessageById(long) or similar means, unless the member is already cached.

        Returns:
        Message author, or null if the message was not sent in a TextChannel, or if the message was sent by a Webhook.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        See Also:
        isWebhookMessage()
      • getJumpUrl

        @Nonnull
        java.lang.String getJumpUrl()
        Returns the jump-to URL for the received message. Clicking this URL in the Discord client will cause the client to jump to the specified message.
        Returns:
        A String representing the jump-to URL for the message
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getContentDisplay

        @Nonnull
        java.lang.String getContentDisplay()
        The textual content of this message in the format that would be shown to the Discord client. All IMentionable entities will be resolved to the format shown by the Discord client instead of the <id> format.

        This includes resolving:
        Users / Members to their @Username/@Nickname format,
        TextChannels to their #ChannelName format,
        Roles to their @RoleName format
        Emotes (not emojis!) to their :name: format.

        If you want the actual Content (mentions as <@id>), use getContentRaw() instead

        Returns:
        The textual content of the message with mentions resolved to be visually like the Discord client.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getContentRaw

        @Nonnull
        java.lang.String getContentRaw()
        The raw textual content of this message. Does not resolve IMentionable entities like getContentDisplay() does. This means that this is the completely raw textual content of the message received from Discord and can contain mentions specified by Discord's Message Formatting.
        Returns:
        The raw textual content of the message, containing unresolved Discord message formatting.
      • getContentStripped

        @Nonnull
        java.lang.String getContentStripped()
        Gets the textual content of this message using getContentDisplay() and then strips it of markdown characters like *, **, __, ~~, || that provide text formatting. Any characters that match these but are not being used for formatting are escaped to prevent possible formatting.
        Returns:
        The textual content from getContentDisplay() with all text formatting characters removed or escaped.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getInvites

        @Nonnull
        java.util.List<java.lang.String> getInvites()
        Creates an immutable List of Invite codes that are included in this Message.
        This will use the Pattern provided under INVITE_PATTERN to construct a Matcher that will parse the getContentRaw() output and include all codes it finds in a list.

        You can use the codes to retrieve/validate invites via Invite.resolve(JDA, String)

        Returns:
        Immutable list of invite codes
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • isFromType

        boolean isFromType​(@Nonnull
                           ChannelType type)
        Used to determine if this Message was received from a MessageChannel of the ChannelType specified.
        This will always be false for ChannelType.VOICE as Messages can't be sent to VoiceChannels.

        Useful for restricting functionality to a certain type of channels.

        Parameters:
        type - The ChannelType to check against.
        Returns:
        True if the ChannelType which this message was received from is the same as the one specified by type.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • isFromGuild

        default boolean isFromGuild()
        Whether this message was sent in a Guild.
        If this is false then getGuild() will throw an IllegalStateException.
        Returns:
        True, if getChannelType().isGuild() is true.
      • getChannelType

        @Nonnull
        ChannelType getChannelType()
        Gets the ChannelType that this message was received from.
        This will never be ChannelType.VOICE as Messages can't be sent to VoiceChannels.
        Returns:
        The ChannelType which this message was received from.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • isWebhookMessage

        boolean isWebhookMessage()
        Indicates if this Message was sent by a Webhook instead of a User.
        Useful if you want to ignore non-users.
        Returns:
        True if this message was sent by a Webhook.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getChannel

        @Nonnull
        MessageChannel getChannel()
        Returns the MessageChannel that this message was sent in.
        Returns:
        The MessageChannel of this Message
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getCategory

        @Nullable
        Category getCategory()
        The Category this message was sent in. This will always be null for DMs.
        Equivalent to getTextChannel().getParent() if this was sent in a TextChannel.
        Returns:
        Category for this message
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getAttachments

        @Nonnull
        java.util.List<Message.Attachment> getAttachments()
        An immutable list of Attachments that are attached to this message.
        Most likely this will only ever be 1 Attachment at most.
        Returns:
        Immutable list of Attachments.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getEmbeds

        @Nonnull
        java.util.List<MessageEmbed> getEmbeds()
        An immutable list of MessageEmbeds that are part of this Message.
        Returns:
        Immutable list of all given MessageEmbeds.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getButtons

        @Nonnull
        default java.util.List<Button> getButtons()
        All Buttons attached to this message.
        Returns:
        Immutable List of Buttons
      • getButtonById

        @Nullable
        default Button getButtonById​(@Nonnull
                                     java.lang.String id)
        Gets the Button with the specified ID.
        Parameters:
        id - The id of the button
        Returns:
        The Button or null of no button with that ID is present on this message
        Throws:
        java.lang.IllegalArgumentException - If the id is null
      • getButtonsByLabel

        @Nonnull
        default java.util.List<Button> getButtonsByLabel​(@Nonnull
                                                         java.lang.String label,
                                                         boolean ignoreCase)
        All Buttons with the specified label attached to this message.
        Parameters:
        label - The button label
        ignoreCase - Whether to use String.equalsIgnoreCase(String) instead of String.equals(Object)
        Returns:
        Immutable List of Buttons with the specified label
        Throws:
        java.lang.IllegalArgumentException - If the provided label is null
      • getEmotes

        @Nonnull
        java.util.List<Emote> getEmotes()
        All Emotes used in this Message.
        This only includes Custom Emotes, not unicode Emojis. JDA classifies Emotes as the Custom Emojis uploaded to a Guild and retrievable with Guild.getEmotes(). These are not the same as the unicode emojis that Discord also supports. Elements are sorted in order of appearance.

        Unicode emojis are not included as Emote!

        Returns:
        An immutable list of the Emotes used in this message (example match <:jda:230988580904763393>)
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getEmotesBag

        @Nonnull
        org.apache.commons.collections4.Bag<Emote> getEmotesBag()
        A Bag of emotes used in this message.
        This can be used to retrieve the amount of times an emote was used in this message.

        Example

        
         public void sendCount(Message msg)
         {
             List<Emote> emotes = msg.getEmotes(); // distinct list, in order of appearance
             Bag<Emote> count = msg.getEmotesBag();
             StringBuilder content = new StringBuilder();
             for (Emote emote : emotes)
             {
                 content.append(emote.getName())
                        .append(": ")
                        .append(count.getCount(role))
                        .append("\n");
             }
             msg.getChannel().sendMessage(content.toString()).queue();
         }
         
        Returns:
        Bag of used emotes
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        See Also:
        getEmotes()
      • getReactions

        @Nonnull
        java.util.List<MessageReaction> getReactions()
        All MessageReactions that are on this Message.
        Returns:
        Immutable list of all MessageReactions on this message.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getStickers

        @Nonnull
        java.util.List<MessageSticker> getStickers()
        All MessageStickers that are in this Message.
        The returned MessageStickers may only contain necessary information such as the sticker id, format type, name, and icon url.
        Returns:
        Immutable list of all MessageStickers in this message.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • isTTS

        boolean isTTS()
        Defines whether or not this Message triggers TTS (Text-To-Speech).
        Returns:
        If this message is TTS.
      • getActivity

        @Nullable
        MessageActivity getActivity()
        A MessageActivity that contains its type and party id.
        Returns:
        The activity, or null if no activity was added to the message.
      • editMessage

        @Nonnull
        @CheckReturnValue
        MessageAction editMessage​(@Nonnull
                                  java.lang.CharSequence newContent)
        Edits this Message's content to the provided String.
        Messages can only be edited by the account that sent them!.

        This message instance will not be updated by this operation, please use the response message instead.

        The following ErrorResponses are possible:

        Parameters:
        newContent - the new content of the Message
        Returns:
        MessageAction
        The Message with the updated content
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        java.lang.IllegalStateException - If the message attempting to be edited was not created by the currently logged in account, or if newContent's length is 0 or greater than 2000.
      • editMessage

        @Nonnull
        @CheckReturnValue
        @Deprecated
        @ForRemoval(deadline="5.0.0")
        @ReplaceWith("editMessageEmbeds(newEmbed)")
        @DeprecatedSince("4.4.0")
        default MessageAction editMessage​(@Nonnull
                                          MessageEmbed newContent)
        Deprecated.
        Edits this Message's content to the provided MessageEmbed.
        Messages can only be edited by the account that sent them!.

        This message instance will not be updated by this operation, please use the response message instead.

        The following ErrorResponses are possible:

        Parameters:
        newContent - the new content of the Message
        Returns:
        MessageAction
        The Message with the updated content
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        java.lang.IllegalStateException - If the message attempting to be edited was not created by the currently logged in account, or if the passed-in embed is null or not sendable
      • editMessageEmbeds

        @Nonnull
        @CheckReturnValue
        MessageAction editMessageEmbeds​(@Nonnull
                                        java.util.Collection<? extends MessageEmbed> embeds)
        Edits this Message's content to the provided MessageEmbeds.
        Messages can only be edited by the account that sent them!.

        This message instance will not be updated by this operation, please use the response message instead.

        The following ErrorResponses are possible:

        Parameters:
        embeds - the new embeds of the Message (up to 10)
        Returns:
        MessageAction
        The Message with the updated content
        Throws:
        java.lang.UnsupportedOperationException - If this is not a Received Message from MessageType.DEFAULT
        java.lang.IllegalStateException - If the message attempting to be edited was not created by the currently logged in account
        java.lang.IllegalArgumentException - if any of the passed-in embeds is null or not sendable.
      • editMessageEmbeds

        @Nonnull
        @CheckReturnValue
        default MessageAction editMessageEmbeds​(@Nonnull
                                                MessageEmbed... embeds)
        Edits this Message's content to the provided MessageEmbeds.
        Messages can only be edited by the account that sent them!.

        This message instance will not be updated by this operation, please use the response message instead.

        The following ErrorResponses are possible:

        Parameters:
        embeds - the new embeds of the Message (up to 10)
        Returns:
        MessageAction
        The Message with the updated content
        Throws:
        java.lang.UnsupportedOperationException - If this is not a Received Message from MessageType.DEFAULT
        java.lang.IllegalStateException - If the message attempting to be edited was not created by the currently logged in account
        java.lang.IllegalArgumentException - if any of the passed-in embeds is null or not sendable.
      • editMessageComponents

        @Nonnull
        @CheckReturnValue
        MessageAction editMessageComponents​(@Nonnull
                                            java.util.Collection<? extends ComponentLayout> components)
        Edits this Message's content to the provided ComponentLayouts.
        Messages can only be edited by the account that sent them!.
        This will replace all the current Components, such as Buttons or SelectionMenus on this message. The provided parameters are ComponentLayout such as ActionRow which contain a list of components to arrange in the respective layout.

        This message instance will not be updated by this operation, please use the response message instead.

        The following ErrorResponses are possible:

        • INVALID_AUTHOR_EDIT
          Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!
        • MISSING_ACCESS
          The request was attempted after the account lost access to the Guild typically due to being kicked or removed, or after Permission.MESSAGE_READ was revoked in the TextChannel
        • UNKNOWN_MESSAGE
          If the message has already been deleted. This might also be triggered for ephemeral messages.
        • UNKNOWN_CHANNEL
          The request was attempted after the channel was deleted.

        Example

        
         List<ActionRow> rows = Arrays.asList(
           ActionRow.of(Button.success("prompt:accept", "Accept"), Button.danger("prompt:reject", "Reject")), // 1st row below message
           ActionRow.of(Button.link(url, "Help")) // 2nd row below message
         );
         message.editMessageComponents(rows).queue();
         
        Parameters:
        components - Up to 5 new ComponentLayouts for the edited message, such as ActionRow
        Returns:
        MessageAction
        The Message with the updated components
        Throws:
        java.lang.UnsupportedOperationException - If this is not a Received Message from MessageType.DEFAULT or any of the component layouts is a custom implementation that is not supported by this interface
        java.lang.IllegalArgumentException - If null is provided, or more than 5 layouts are added
        java.lang.IllegalStateException - If the message attempting to be edited was not created by the currently logged in account
      • editMessageComponents

        @Nonnull
        @CheckReturnValue
        default MessageAction editMessageComponents​(@Nonnull
                                                    ComponentLayout... components)
        Edits this Message's content to the provided ComponentLayouts.
        Messages can only be edited by the account that sent them!.
        This will replace all the current Components, such as Buttons or SelectionMenus on this message. The provided parameters are ComponentLayout such as ActionRow which contain a list of components to arrange in the respective layout.

        This message instance will not be updated by this operation, please use the response message instead.

        The following ErrorResponses are possible:

        • INVALID_AUTHOR_EDIT
          Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!
        • MISSING_ACCESS
          The request was attempted after the account lost access to the Guild typically due to being kicked or removed, or after Permission.MESSAGE_READ was revoked in the TextChannel
        • UNKNOWN_MESSAGE
          If the message has already been deleted. This might also be triggered for ephemeral messages.
        • UNKNOWN_CHANNEL
          The request was attempted after the channel was deleted.

        Example

        
         message.editMessageComponents(
           ActionRow.of(Button.success("prompt:accept", "Accept"), Button.danger("prompt:reject", "Reject")), // 1st row below message
           ActionRow.of(Button.link(url, "Help")) // 2nd row below message
         ).queue();
         
        Parameters:
        components - Up to 5 new ComponentLayouts for the edited message, such as ActionRow
        Returns:
        MessageAction
        The Message with the updated components
        Throws:
        java.lang.UnsupportedOperationException - If this is not a Received Message from MessageType.DEFAULT or any of the component layouts is a custom implementation that is not supported by this interface
        java.lang.IllegalArgumentException - If null is provided, or more than 5 layouts are added
        java.lang.IllegalStateException - If the message attempting to be edited was not created by the currently logged in account
      • editMessageFormat

        @Nonnull
        @CheckReturnValue
        MessageAction editMessageFormat​(@Nonnull
                                        java.lang.String format,
                                        @Nonnull
                                        java.lang.Object... args)
        Edits this Message's content to the provided format.
        Shortcut for MessageBuilder.appendFormat(String, Object...).
        Messages can only be edited by the account that sent them!.

        This message instance will not be updated by this operation, please use the response message instead.

        The following ErrorResponses are possible:

        Parameters:
        format - Format String used to generate the Message's content via MessageBuilder.appendFormat(String, Object...) specification
        args - The arguments to use in order to be converted in the format string
        Returns:
        MessageAction
        The Message with the updated content
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        java.lang.IllegalArgumentException - If the provided format String is null or blank, or if the created message exceeds the 2000 character limit
        java.util.IllegalFormatException - If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.
        java.lang.IllegalStateException - If the message attempting to be edited was not created by the currently logged in account
      • editMessage

        @Nonnull
        @CheckReturnValue
        MessageAction editMessage​(@Nonnull
                                  Message newContent)
        Edits this Message's content to the provided Message.
        Messages can only be edited by the account that sent them!.

        This message instance will not be updated by this operation, please use the response message instead.

        The following ErrorResponses are possible:

        Parameters:
        newContent - the new content of the Message
        Returns:
        MessageAction
        The Message with the updated content
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        java.lang.IllegalStateException -
        • If the message attempting to be edited was not created by the currently logged in account
        • If the message contains a MessageEmbed that is not sendable
      • replyFormat

        @Nonnull
        @CheckReturnValue
        default MessageAction replyFormat​(@Nonnull
                                          java.lang.String format,
                                          @Nonnull
                                          java.lang.Object... args)
        Replies and references this message.
        This is identical to message.getChannel().sendMessageFormat(content, args).reference(message). You can use mentionRepliedUser(false) to not mention the author of the message.
        By default there won't be any error thrown if the referenced message does not exist. This behavior can be changed with MessageAction.failOnInvalidReply(boolean).

        For further info, see MessageChannel.sendMessageFormat(String, Object...) and MessageAction.reference(Message).

        Parameters:
        format - The string that should be formatted, if this is null or empty the content of the Message would be empty and cause a builder exception.
        args - The arguments for your format
        Returns:
        MessageAction Providing the Message created from this upload.
        Since:
        4.2.1
      • getJDA

        @Nonnull
        JDA getJDA()
        Returns the JDA instance related to this Message.
        Returns:
        the corresponding JDA instance
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • isPinned

        boolean isPinned()
        Whether or not this Message has been pinned in its parent channel.
        Returns:
        True - if this message has been pinned.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • addReaction

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> addReaction​(@Nonnull
                                               java.lang.String unicode)
        Adds a reaction to this Message using a unicode emoji.
        A reference of unicode emojis can be found here: Emoji Table.

        This message instance will not be updated by this operation.

        Reactions are the small emoji/emotes below a message that have a counter beside them showing how many users have reacted with the same emoji/emote.

        Neither success nor failure of this request will affect this Message's getReactions() return as Message is immutable.

        Examples

        // custom
        message.addReaction("minn:245267426227388416").queue();
        // unicode escape
        message.addReaction("\uD83D\uDE02").queue();
        // codepoint notation
        message.addReaction("U+1F602").queue();

        The following ErrorResponses are possible:

        Parameters:
        unicode - The unicode emoji to add as a reaction to this Message.
        Returns:
        RestAction - Type: Void
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        InsufficientPermissionException - If the MessageChannel this message was sent in was a TextChannel and the logged in account does not have
        java.lang.IllegalArgumentException - If the provided unicode emoji is null or empty.
        java.lang.IllegalStateException - If this Message is ephemeral
      • clearReactions

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> clearReactions()
        Removes all reactions from this Message.
        This is useful for moderator commands that wish to remove all reactions at once from a specific message.

        Please note that you can't clear reactions if this message was sent in a PrivateChannel!

        Neither success nor failure of this request will affect this Message's getReactions() return as Message is immutable.

        The following ErrorResponses are possible:

        Returns:
        RestAction - Type: Void
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        InsufficientPermissionException - If the MessageChannel this message was sent in was a TextChannel and the currently logged in account does not have Permission.MESSAGE_MANAGE in the channel.
        java.lang.IllegalStateException -
        • If this message was not sent in a Guild.
        • If this message is ephemeral
      • clearReactions

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> clearReactions​(@Nonnull
                                                  java.lang.String unicode)
        Removes all reactions for the specified emoji.

        Please note that you can't clear reactions if this message was sent in a PrivateChannel!

        Example

        
         // custom
         message.clearReactions("minn:245267426227388416").queue();
         // unicode escape
         message.clearReactions("\uD83D\uDE02").queue();
         // codepoint notation
         message.clearReactions("U+1F602").queue();
         

        The following ErrorResponses are possible:

        • MISSING_ACCESS
          The currently logged in account lost access to the channel by either being removed from the guild or losing the VIEW_CHANNEL permission
        • 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
        • UNKNOWN_MESSAGE
          If the message has already been deleted. This might also be triggered for ephemeral messages.
        Parameters:
        unicode - The unicode emoji to remove reactions for
        Returns:
        RestAction
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        InsufficientPermissionException - If the currently logged in account does not have Permission.MESSAGE_MANAGE in the channel
        java.lang.IllegalArgumentException - If provided with null
        java.lang.IllegalStateException -
        • If this message was not sent in a Guild.
        • If this message is ephemeral
        Since:
        4.2.0
      • clearReactions

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> clearReactions​(@Nonnull
                                                  Emote emote)
        Removes all reactions for the specified emote.

        Please note that you can't clear reactions if this message was sent in a PrivateChannel!

        The following ErrorResponses are possible:

        • MISSING_ACCESS
          The currently logged in account lost access to the channel by either being removed from the guild or losing the VIEW_CHANNEL permission
        • UNKNOWN_EMOJI
          The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.
        • UNKNOWN_MESSAGE
          If the message has already been deleted. This might also be triggered for ephemeral messages.
        Parameters:
        emote - The Emote to remove reactions for
        Returns:
        RestAction
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        InsufficientPermissionException - If the currently logged in account does not have Permission.MESSAGE_MANAGE in the channel
        java.lang.IllegalArgumentException - If provided with null
        java.lang.IllegalStateException -
        • If this message was not sent in a Guild.
        • If this message is ephemeral
        Since:
        4.2.0
      • removeReaction

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> removeReaction​(@Nonnull
                                                  Emote emote)
        Removes a reaction from this Message using an Emote.

        This message instance will not be updated by this operation.

        Reactions are the small emoji/emotes below a message that have a counter beside them showing how many users have reacted with the same emoji/emote.

        Neither success nor failure of this request will affect this Message's getReactions() return as Message is immutable.

        Unicode emojis are not included as Emote!

        The following ErrorResponses are possible:

        Parameters:
        emote - The Emote to remove as a reaction from this Message.
        Returns:
        RestAction - Type: Void
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        InsufficientPermissionException - If the MessageChannel this message was sent in was a TextChannel and the logged in account does not have Permission.MESSAGE_HISTORY
        java.lang.IllegalArgumentException -
        java.lang.IllegalStateException - If this is an ephemeral message
        Since:
        4.1.0
      • removeReaction

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> removeReaction​(@Nonnull
                                                  Emote emote,
                                                  @Nonnull
                                                  User user)
        Removes a User's reaction from this Message using an Emote.

        Please note that you can't remove reactions of other users if this message was sent in a PrivateChannel!

        This message instance will not be updated by this operation.

        Reactions are the small emoji/emotes below a message that have a counter beside them showing how many users have reacted with the same emoji/emote.

        Neither success nor failure of this request will affect this Message's getReactions() return as Message is immutable.

        Unicode emojis are not included as Emote!

        The following ErrorResponses are possible:

        Parameters:
        emote - The Emote to remove as a reaction from this Message.
        user - The User to remove the reaction for.
        Returns:
        RestAction - Type: Void
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        InsufficientPermissionException - If the MessageChannel this message was sent in was a TextChannel and the logged in account does not have Permission.MESSAGE_HISTORY.
        java.lang.IllegalArgumentException -
        java.lang.IllegalStateException -
        • If this message was not sent in a Guild and the given user is not the SelfUser.
        • If this message is ephemeral
        Since:
        4.1.0
      • removeReaction

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> removeReaction​(@Nonnull
                                                  java.lang.String unicode)
        Removes a reaction from this Message using a unicode emoji.
        A reference of unicode emojis can be found here: Emoji Table.

        This message instance will not be updated by this operation.

        Reactions are the small emoji/emotes below a message that have a counter beside them showing how many users have reacted with the same emoji/unicode.

        Neither success nor failure of this request will affect this Message's getReactions() return as Message is immutable.

        Examples

        // custom
        message.removeReaction("minn:245267426227388416").queue();
        // unicode escape
        message.removeReaction("\uD83D\uDE02").queue();
        // codepoint notation
        message.removeReaction("U+1F602").queue();

        The following ErrorResponses are possible:

        Parameters:
        unicode - The unicode emoji to add as a reaction to this Message.
        Returns:
        RestAction - Type: Void
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        InsufficientPermissionException - If the MessageChannel this message was sent in was a TextChannel and the logged in account does not have Permission.MESSAGE_HISTORY
        java.lang.IllegalArgumentException - If the provided unicode emoji is null or empty.
        java.lang.IllegalStateException - If this is an ephemeral message
        Since:
        4.1.0
      • removeReaction

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> removeReaction​(@Nonnull
                                                  java.lang.String unicode,
                                                  @Nonnull
                                                  User user)
        Removes a reaction from this Message using a unicode emoji.
        A reference of unicode emojis can be found here: Emoji Table.

        Please note that you can't remove reactions of other users if this message was sent in a PrivateChannel!

        This message instance will not be updated by this operation.

        Reactions are the small emoji/emotes below a message that have a counter beside them showing how many users have reacted with the same emoji/unicode.

        Neither success nor failure of this request will affect this Message's getReactions() return as Message is immutable.

        The following ErrorResponses are possible:

        Parameters:
        unicode - The unicode emoji to add as a reaction to this Message.
        user - The User to remove the reaction for.
        Returns:
        RestAction - Type: Void
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        InsufficientPermissionException - If the MessageChannel this message was sent in was a TextChannel and the logged in account does not have
        java.lang.IllegalArgumentException - If the provided unicode emoji is null or empty or if the provided user is null.
        java.lang.IllegalStateException - If this message:
        • Was not sent in a Guild and the given user is not the SelfUser.
        • Is ephemeral
        Since:
        4.1.0
      • retrieveReactionUsers

        @Nonnull
        @CheckReturnValue
        ReactionPaginationAction retrieveReactionUsers​(@Nonnull
                                                       java.lang.String unicode)
        This obtains the users who reacted 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 ReactionPaginationAction of the users who've reacted to this message.

        The following ErrorResponses are possible:

        Parameters:
        unicode - The unicode emote to retrieve users for.
        Returns:
        The ReactionPaginationAction of the emoji's users.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        InsufficientPermissionException - If the MessageChannel this message was sent in was a TextChannel and the logged in account does not have Permission.MESSAGE_HISTORY in the channel.
        java.lang.IllegalArgumentException - If the provided unicode emoji is null or empty.
        java.lang.IllegalStateException - If this Message is ephemeral
        Since:
        4.1.0
      • getReactionByUnicode

        @Nullable
        @CheckReturnValue
        MessageReaction.ReactionEmote getReactionByUnicode​(@Nonnull
                                                           java.lang.String unicode)
        This obtains the ReactionEmote for the given unicode reaction on this message.

        Messages also store reactions using unicode values.

        An instance of the related ReactionEmote can be obtained through this method by using the emoji's unicode value.

        Parameters:
        unicode - The unicode value of the reaction emoji.
        Returns:
        The ReactionEmote of this message or null if not present.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        java.lang.IllegalArgumentException - If the provided unicode value is null or empty.
        Since:
        4.1.0
      • getReactionById

        @Nullable
        @CheckReturnValue
        MessageReaction.ReactionEmote getReactionById​(@Nonnull
                                                      java.lang.String id)
        This obtains the ReactionEmote for the given reaction id on this message.

        Messages store reactions by keeping a list of reaction names.

        An instance of the related ReactionEmote can be obtained through this method by using the emote's id.

        Parameters:
        id - The string id of the reaction emote.
        Returns:
        The ReactionEmote of this message or null if not present.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        java.lang.IllegalArgumentException - If the provided id is not a valid snowflake.
        Since:
        4.1.0
      • getReactionById

        @Nullable
        @CheckReturnValue
        MessageReaction.ReactionEmote getReactionById​(long id)
        This obtains the ReactionEmote for the given reaction id on this message.

        Messages store reactions by keeping a list of reaction names.

        An instance of the related ReactionEmote can be obtained through this method by using the emote's id.

        Parameters:
        id - The long id of the reaction emote.
        Returns:
        The ReactionEmote of this message or null if not present.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        Since:
        4.1.0
      • isSuppressedEmbeds

        boolean isSuppressedEmbeds()
        Whether embeds are suppressed for this message. When Embeds are suppressed, they are not displayed on clients nor provided via API until un-suppressed.
        This is a shortcut method for checking if getFlags() contains MessageFlag#EMBEDS_SUPPRESSED
        Returns:
        Whether or not Embeds are suppressed for this Message.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        See Also:
        suppressEmbeds(boolean)
      • getFlagsRaw

        long getFlagsRaw()
        Returns the raw message flags of this message
        Returns:
        The raw message flags
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
        See Also:
        getFlags()
      • isEphemeral

        boolean isEphemeral()
        Whether this message is ephemeral.
        The message being ephemeral means it is only visible to the bot and the interacting user
        This is a shortcut method for checking if getFlags() contains Message.MessageFlag.EPHEMERAL
        Returns:
        Whether the message is ephemeral
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getType

        @Nonnull
        MessageType getType()
        This specifies the MessageType of this Message.

        Messages can represent more than just simple text sent by Users, they can also be special messages that inform about events that occur. Messages can either be default messages or special messages like welcome messages.

        Returns:
        The MessageType of this message.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message
      • getInteraction

        @Nullable
        Message.Interaction getInteraction()
        This is sent on the message object when the message is a response to an Interaction without an existing message.

        This means responses to Message Components do not include this property, instead including a message reference object as components always exist on preexisting messages.

        Returns:
        The Interaction of this message.
        Throws:
        java.lang.UnsupportedOperationException - If this is a system message