Interface MessageChannel

  • All Superinterfaces:
    java.util.Formattable, ISnowflake
    All Known Subinterfaces:
    Group, PrivateChannel, TextChannel

    public interface MessageChannel
    extends ISnowflake, java.util.Formattable
    Represents a Discord channel that can have Messages and files sent to it.

    Formattable

    This interface extends Formattable and can be used with a Formatter such as used by String.format(String, Object...) or PrintStream.printf(String, Object...).

    This will use getName() rather than Object.toString()!
    Supported Features:

    • Alternative
      - Prepends the name with # (Example: %#s - results in #getName())
    • Width/Left-Justification
      - Ensures the size of a format (Example: %20s - uses at minimum 20 chars; %-10s - uses left-justified padding)
    • Precision
      - Cuts the content to the specified size (Example: %.20s)

    More information on formatting syntax can be found in the format syntax documentation!
    TextChannel is a special case which uses IMentionable.getAsMention() by default and uses the #getName() format as alternative

    • Method Detail

      • getLatestMessageId

        default java.lang.String getLatestMessageId()
        The id for the most recent message sent in this current MessageChannel.
        This should only be used if hasLatestMessage() returns true!

        This value is updated on each MessageReceivedEvent and will be reset to null if the message associated with this ID gets deleted

        Returns:
        The most recent message's id
        Throws:
        java.lang.IllegalStateException - If no message id is available
      • purgeMessages

        default java.util.List<RequestFuture<java.lang.Void>> purgeMessages​(Message... messages)
        Convenience method to delete messages in the most efficient way available.
        This combines both TextChannel.deleteMessagesByIds(Collection) as well as Message.delete() to delete all messages provided. No checks will be done to prevent failures, use CompletionStage.exceptionally(Function) to handle failures.

        For possible ErrorResponses see purgeMessagesById(long...).

        Parameters:
        messages - The messages to delete
        Returns:
        List of futures representing all deletion tasks
        Throws:
        InsufficientPermissionException - If one of the provided messages is from another user and cannot be deleted due to permissions
        java.lang.IllegalArgumentException - If one of the provided messages is from another user and cannot be deleted because this is not in a guild
        See Also:
        RequestFuture.allOf(Collection)
      • purgeMessages

        default java.util.List<RequestFuture<java.lang.Void>> purgeMessages​(java.util.List<? extends Message> messages)
        Convenience method to delete messages in the most efficient way available.
        This combines both TextChannel.deleteMessagesByIds(Collection) as well as Message.delete() to delete all messages provided. No checks will be done to prevent failures, use CompletionStage.exceptionally(Function) to handle failures.

        For possible ErrorResponses see purgeMessagesById(long...).

        Parameters:
        messages - The messages to delete
        Returns:
        List of futures representing all deletion tasks
        Throws:
        InsufficientPermissionException - If one of the provided messages is from another user and cannot be deleted due to permissions
        java.lang.IllegalArgumentException - If one of the provided messages is from another user and cannot be deleted because this is not in a guild
        See Also:
        RequestFuture.allOf(Collection)
      • getLatestMessageIdLong

        long getLatestMessageIdLong()
        The id for the most recent message sent in this current MessageChannel.
        This should only be used if hasLatestMessage() returns true!

        This value is updated on each MessageReceivedEvent and will be reset to null if the message associated with this ID gets deleted

        Returns:
        The most recent message's id
        Throws:
        java.lang.IllegalStateException - If no message id is available
      • hasLatestMessage

        boolean hasLatestMessage()
        Whether this MessageChannel contains a tracked most recent message or not.

        This does not directly mean that getHistory() will be unable to retrieve past messages, it merely means that the latest message is untracked by our internal cache meaning that if this returns false the getLatestMessageId() method will throw an NoSuchElementException

        Returns:
        True, if a latest message id is available for retrieval by getLatestMessageId()
        See Also:
        getLatestMessageId()
      • getName

        java.lang.String getName()
        This method is a shortcut method to return the following information in the following situation: If the MessageChannel is instance of..
        Returns:
        Possibly-null "name" of the MessageChannel. Different implementations determine what the name. Only Group could have a null name.
      • getType

        ChannelType getType()
        The ChannelType of this MessageChannel.
        Returns:
        The ChannelType for this channel
      • getJDA

        JDA getJDA()
        Returns the JDA instance of this MessageChannel
        Returns:
        the corresponding JDA instance
      • sendMessageFormat

        @CheckReturnValue
        default MessageAction sendMessageFormat​(java.lang.String format,
                                                java.lang.Object... args)
        Sends a formatted text message to this channel.
        This will fail if this channel is an instance of TextChannel and the currently logged in account does not have permissions to send a message to this channel.
        To determine if you are able to send a message in a TextChannel use TextChannel.canTalk().

        This method is a shortcut to sendMessage(Message) by way of using a MessageBuilder and using its MessageBuilder.appendFormat(String, Object...) method.
        For more information on how to format your input, refer to the docs of the method mentioned above.

        For ErrorResponse information, refer to sendMessage(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
        The newly created Message after it has been sent to Discord.
        Throws:
        InsufficientPermissionException - If this is a TextChannel and the logged in account does not have
        VerificationLevelException - If this is a TextChannel and TextChannel.getGuild().checkVerification() returns false.
        java.lang.IllegalArgumentException - If the provided format text is null, empty or longer than 2000 characters
        java.lang.UnsupportedOperationException - If this is a PrivateChannel and both the currently logged in account and the target user are bots.
        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.
      • sendFile

        @CheckReturnValue
        default MessageAction sendFile​(java.io.File file,
                                       java.lang.String fileName)
        Uploads a file to the Discord servers and sends it to this MessageChannel. Sends the provided Message with the uploaded file.
        If you do not wish to send a Message with the uploaded file, you can provide null for the message parameter.

        The fileName parameter is used to inform Discord about what the file should be called. This is 2 fold:

        1. The file name provided is the name that is found in Message.Attachment.getFileName() after upload and it is the name that will show up in the client when the upload is displayed.
          Note: The fileName does not show up on the Desktop client for images. It does on mobile however.
        2. The extension of the provided fileName also determines who Discord will treat the file. Discord currently only has special handling for image file types, but the fileName's extension must indicate that it is an image file. This means it has to end in something like .png, .jpg, .jpeg, .gif, etc. As a note, you can also not provide a full name for the file and instead ONLY provide the extension like "png" or "gif" and Discord will generate a name for the upload and append the fileName as the extension.

        For ErrorResponse information, refer to the documentation for sendFile(java.io.File, String, Message).

        Parameters:
        file - The file to upload to the MessageChannel.
        fileName - The name that should be sent to discord
        Returns:
        MessageAction
        The Message created from this upload.
        Throws:
        java.lang.IllegalArgumentException -
        • Provided file is null.
        • Provided file does not exist.
        • Provided file is unreadable.
        • Provided file is greater than 8MiB for normal and 50MiB for nitro accounts.
        • Provided Message is not null and contains a MessageEmbed which is not sendable
        PermissionException - If this is a TextChannel and the logged in account does not have
        java.lang.UnsupportedOperationException - If this is a PrivateChannel and both the currently logged in account and the target user are bots.
      • sendFile

        @CheckReturnValue
        default MessageAction sendFile​(java.io.File file,
                                       Message message)
        Uploads a file to the Discord servers and sends it to this MessageChannel. Sends the provided Message with the uploaded file.
        If you do not wish to send a Message with the uploaded file, you can provide null for the message parameter.

        This is a shortcut to sendFile(java.io.File, String, Message) by way of using File.getName().

        sendFile(file, file.getName(), message)

        Uploading images with Embeds
        When uploading an image you can reference said image using the specified filename as URI attachment://filename.ext.

        Example

        
         MessageChannel channel; // = reference of a MessageChannel
         MessageBuilder message = new MessageBuilder();
         EmbedBuilder embed = new EmbedBuilder();
         File file = new File("cat.gif");
         embed.setImage("attachment://cat.gif")
              .setDescription("This is a cute cat :3");
         message.setEmbed(embed.build());
         channel.sendFile(file, message.build()).queue();
         

        For ErrorResponse information, refer to the documentation for sendFile(java.io.File, String, Message).

        Parameters:
        file - The file to upload to the MessageChannel.
        message - The message to be sent along with the uploaded file. This value can be null.
        Returns:
        MessageAction
        The Message created from this upload.
        Throws:
        java.lang.IllegalArgumentException -
        • Provided file is null.
        • Provided file does not exist.
        • Provided file is unreadable.
        • Provided file is greater than 8 MiB on a normal or 50 MiB on a nitro account.
        • Provided Message is not null and contains a MessageEmbed which is not sendable
        InsufficientPermissionException - If this is a TextChannel and the logged in account does not have
        java.lang.UnsupportedOperationException - If this is a PrivateChannel and both the currently logged in account and the target user are bots.
      • sendFile

        @CheckReturnValue
        default MessageAction sendFile​(java.io.File file,
                                       java.lang.String fileName,
                                       Message message)
        Uploads a file to the Discord servers and sends it to this MessageChannel. Sends the provided Message with the uploaded file.
        If you do not wish to send a Message with the uploaded file, you can provide null for the message parameter.

        The fileName parameter is used to inform Discord about what the file should be called. This is 2 fold:

        1. The file name provided is the name that is found in Message.Attachment.getFileName() after upload and it is the name that will show up in the client when the upload is displayed.
          Note: The fileName does not show up on the Desktop client for images. It does on mobile however.
        2. The extension of the provided fileName also determines who Discord will treat the file. Discord currently only has special handling for image file types, but the fileName's extension must indicate that it is an image file. This means it has to end in something like .png, .jpg, .jpeg, .gif, etc. As a note, you can also not provide a full name for the file and instead ONLY provide the extension like "png" or "gif" and Discord will generate a name for the upload and append the fileName as the extension.

        Uploading images with Embeds
        When uploading an image you can reference said image using the specified filename as URI attachment://filename.ext.

        Example

        
         MessageChannel channel; // = reference of a MessageChannel
         MessageBuilder message = new MessageBuilder();
         EmbedBuilder embed = new EmbedBuilder();
         File file = new File("cat_01.gif");
         embed.setImage("attachment://cat.gif") // we specify this in sendFile as "cat.gif"
              .setDescription("This is a cute cat :3");
         message.setEmbed(embed.build());
         channel.sendFile(file, "cat.gif", message.build()).queue();
         

        The following ErrorResponses are possible:

        Parameters:
        file - The file to upload to the MessageChannel.
        fileName - The name that should be sent to discord
        message - The message to be sent along with the uploaded file. This value can be null.
        Returns:
        MessageAction
        The Message created from this upload.
        Throws:
        java.lang.IllegalArgumentException -
        • Provided file is null.
        • Provided file does not exist.
        • Provided file is unreadable.
        • Provided file is greater than 8 MiB on a normal or 50 MiB on a nitro account.
        • Provided Message is not null and contains a MessageEmbed which is not sendable
        InsufficientPermissionException - If this is a TextChannel and the logged in account does not have
        java.lang.UnsupportedOperationException - If this is a PrivateChannel and both the currently logged in account and the target user are bots.
      • sendFile

        @CheckReturnValue
        default MessageAction sendFile​(java.io.InputStream data,
                                       java.lang.String fileName,
                                       Message message)
        Uploads a file to the Discord servers and sends it to this MessageChannel. Sends the provided Message with the uploaded file.
        If you do not wish to send a Message with the uploaded file, you can provide null for the message parameter.
        This allows you to send an InputStream as substitute to a file.

        For information about the fileName parameter, Refer to the documentation for sendFile(java.io.File, String, Message).
        For ErrorResponse information, refer to the documentation for sendFile(java.io.File, String, Message).

        Uploading images with Embeds
        When uploading an image you can reference said image using the specified filename as URI attachment://filename.ext.

        Example

        
         MessageChannel channel; // = reference of a MessageChannel
         MessageBuilder message = new MessageBuilder();
         EmbedBuilder embed = new EmbedBuilder();
         InputStream file = new URL("https://http.cat/500").openStream();
         embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png"
              .setDescription("This is a cute cat :3");
         message.setEmbed(embed.build());
         channel.sendFile(file, "cat.png", message.build()).queue();
         
        Parameters:
        data - The InputStream data to upload to the MessageChannel.
        fileName - The name that should be sent to discord
        Refer to the documentation for sendFile(java.io.File, String, Message) for information about this parameter.
        message - The message to be sent along with the uploaded file. This value can be null.
        Returns:
        MessageAction
        The Message created from this upload.
        Throws:
        java.lang.IllegalArgumentException - If the provided filename is null or empty.
        InsufficientPermissionException - If this is a TextChannel and the logged in account does not have
        java.lang.UnsupportedOperationException - If this is a PrivateChannel and both the currently logged in account and the target user are bots.
      • sendFile

        @CheckReturnValue
        default MessageAction sendFile​(byte[] data,
                                       java.lang.String fileName,
                                       Message message)
        Uploads a file to the Discord servers and sends it to this MessageChannel. Sends the provided Message with the uploaded file.
        If you do not wish to send a Message with the uploaded file, you can provide null for the message parameter.
        This allows you to send an byte[] as substitute to a file.

        For information about the fileName parameter, Refer to the documentation for sendFile(java.io.File, String, Message).
        For ErrorResponse information, refer to the documentation for sendFile(java.io.File, String, Message).

        Uploading images with Embeds
        When uploading an image you can reference said image using the specified filename as URI attachment://filename.ext.

        Example

        
         MessageChannel channel; // = reference of a MessageChannel
         MessageBuilder message = new MessageBuilder();
         EmbedBuilder embed = new EmbedBuilder();
         byte[] file = IOUtil.readFully(new URL("https://http.cat/500").openStream());
         embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png"
              .setDescription("This is a cute cat :3");
         message.setEmbed(embed.build());
         channel.sendFile(file, "cat.png", message.build()).queue();
         
        Parameters:
        data - The byte[] data to upload to the MessageChannel.
        fileName - The name that should be sent to discord.
        Refer to the documentation for sendFile(java.io.File, String, Message) for information about this parameter.
        message - The message to be sent along with the uploaded file. This value can be null.
        Returns:
        MessageAction
        The Message created from this upload.
        Throws:
        java.lang.IllegalArgumentException -
        • If the provided filename is null or empty or the provided data is larger than 8 MiB on a normal or 50 MiB on a nitro account.
        • If the provided Message contains an MessageEmbed that is not sendable
        InsufficientPermissionException - If this is a TextChannel and the logged in account does not have
        java.lang.UnsupportedOperationException - If this is a PrivateChannel and both the currently logged in account and the target user are bots.
      • getIterableHistory

        @CheckReturnValue
        default MessagePaginationAction getIterableHistory()
        A PaginationAction implementation that allows to iterate over recent Messages of this MessageChannel.
        This is not a cache for received messages and it can only view messages that were sent before. This iterates chronologically backwards (from present to past).

        It is recommended not to use this in an enhanced for-loop without end conditions as it might cause memory overflows in channels with a long message history.

        Examples

        
         public boolean containsMessage(MessageChannel channel, String content, int checkAmount)
         {
             for (Message message : channel.getIterableHistory())
             {
                 if (message.getContentRaw().equals(content))
                     return true;
                 if (checkAmount--<= 0) break;
             }
             return false;
         }
        
         public List<Message> getMessagesByUser(MessageChannel channel, User user)
         {
             return channel.getIterableHistory().stream()
                 .limit(1000)
                 .filter(m-> m.getAuthor().equals(user))
                 .collect(Collectors.toList());
         }
         
        Returns:
        MessagePaginationAction
        Throws:
        InsufficientPermissionException - If this is a TextChannel and the currently logged in account does not have the permission MESSAGE_HISTORY
      • getHistoryAround

        @CheckReturnValue
        default MessageHistory.MessageRetrieveAction getHistoryAround​(java.lang.String messageId,
                                                                      int limit)
        Uses the provided id of a message as a marker and retrieves messages sent around the marker. The limit determines the amount of message retrieved near the marker. Discord will attempt to evenly split the limit between before and after the marker, however in the case that the marker is set near the beginning or near the end of the channel's history the amount of messages on each side of the marker may be different, and their total count may not equal the provided limit.

        Examples:
        Retrieve 100 messages from the middle of history. >100 message exist in history and the marker is >50 messages from the edge of history.
        getHistoryAround(messageId, 100) - This will retrieve 100 messages from history, 50 before the marker and 50 after the marker.

        Retrieve 10 messages near the end of history. Provided id is for a message that is the 3rd most recent message.
        getHistoryAround(messageId, 10) - This will retrieve 10 messages from history, 8 before the marker and 2 after the marker.

        The following ErrorResponses are possible:

        Parameters:
        messageId - The id of the message that will act as a marker.
        limit - The amount of message to be retrieved around the marker. Minimum: 1, Max: 100.
        Returns:
        MessageHistory.MessageRetrieveAction
        Provides a MessageHistory object with message around the provided message loaded into it.
        Throws:
        java.lang.IllegalArgumentException -
        • Provided messageId is null or empty.
        • Provided limit is less than 1 or greater than 100.
        InsufficientPermissionException - If this is a TextChannel and the logged in account does not have
        See Also:
        MessageHistory.getHistoryAround(MessageChannel, String)
      • getHistoryAround

        @CheckReturnValue
        default MessageHistory.MessageRetrieveAction getHistoryAround​(long messageId,
                                                                      int limit)
        Uses the provided id of a message as a marker and retrieves messages around the marker. The limit determines the amount of message retrieved near the marker. Discord will attempt to evenly split the limit between before and after the marker, however in the case that the marker is set near the beginning or near the end of the channel's history the amount of messages on each side of the marker may be different, and their total count may not equal the provided limit.

        Examples:
        Retrieve 100 messages from the middle of history. >100 message exist in history and the marker is >50 messages from the edge of history.
        getHistoryAround(messageId, 100) - This will retrieve 100 messages from history, 50 before the marker and 50 after the marker.

        Retrieve 10 messages near the end of history. Provided id is for a message that is the 3rd most recent message.
        getHistoryAround(messageId, 10) - This will retrieve 10 messages from history, 8 before the marker and 2 after the marker.

        The following ErrorResponses are possible:

        Parameters:
        messageId - The id of the message that will act as a marker. The id must refer to a message from this MessageChannel.
        limit - The amount of message to be retrieved around the marker. Minimum: 1, Max: 100.
        Returns:
        MessageHistory.MessageRetrieveAction
        Provides a MessageHistory object with message around the provided message loaded into it.
        Throws:
        java.lang.IllegalArgumentException -
        • Provided messageId is not positive.
        • Provided limit is less than 1 or greater than 100.
        InsufficientPermissionException - If this is a TextChannel and the logged in account does not have
        See Also:
        MessageHistory.getHistoryAround(MessageChannel, String)
      • getHistoryAround

        @CheckReturnValue
        default MessageHistory.MessageRetrieveAction getHistoryAround​(Message message,
                                                                      int limit)
        Uses the provided Message as a marker and retrieves messages around the marker. The limit determines the amount of message retrieved near the marker. Discord will attempt to evenly split the limit between before and after the marker, however in the case that the marker is set near the beginning or near the end of the channel's history the amount of messages on each side of the marker may be different, and their total count may not equal the provided limit.

        Examples:
        Retrieve 100 messages from the middle of history. >100 message exist in history and the marker is >50 messages from the edge of history.
        getHistoryAround(message, 100) - This will retrieve 100 messages from history, 50 before the marker and 50 after the marker.

        Retrieve 10 messages near the end of history. Provided message is the 3rd most recent message.
        getHistoryAround(message, 10) - This will retrieve 10 messages from history, 8 before the marker and 2 after the marker.

        The following ErrorResponses are possible:

        Parameters:
        message - The Message that will act as a marker. The provided Message must be from this MessageChannel.
        limit - The amount of message to be retrieved around the marker. Minimum: 1, Max: 100.
        Returns:
        MessageHistory.MessageRetrieveAction
        Provides a MessageHistory object with message around the provided message loaded into it.
        Throws:
        java.lang.IllegalArgumentException -
        • Provided message is null.
        • Provided limit is less than 1 or greater than 100.
        InsufficientPermissionException - If this is a TextChannel and the logged in account does not have
        See Also:
        MessageHistory.getHistoryAround(MessageChannel, String)
      • addReactionById

        @CheckReturnValue
        default RestAction<java.lang.Void> addReactionById​(java.lang.String messageId,
                                                           java.lang.String unicode)
        Attempts to react to a message represented by the specified messageId in this MessageChannel.

        The unicode provided has to be a unicode representation of the emoji that is supposed to be represented by the Reaction.
        To retrieve the characters needed you can use an api or the official discord client by escaping the emoji (\:emoji-name:) and copying the resulting emoji from the sent message.

        This method encodes the provided unicode for you. Do not encode the emoji before providing the unicode.

        The following ErrorResponses are possible:

        Parameters:
        messageId - The messageId to attach the reaction to
        unicode - The unicode characters to react with
        Returns:
        RestAction
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided unicode is null or empty.
        InsufficientPermissionException - If the MessageChannel this message was sent in was a TextChannel and the logged in account does not have
      • removeReactionById

        @CheckReturnValue
        default RestAction<java.lang.Void> removeReactionById​(java.lang.String messageId,
                                                              java.lang.String unicode)
        Attempts to remove the reaction from a message represented by the specified messageId in this MessageChannel.

        The unicode provided has to be a unicode representation of the emoji that is supposed to be represented by the Reaction.
        To retrieve the characters needed you can use an api or the official discord client by escaping the emoji (\:emoji-name:) and copying the resulting emoji from the sent message.

        This method encodes the provided unicode for you. Do not encode the emoji before providing the unicode.

        The following ErrorResponses are possible:

        Parameters:
        messageId - The messageId to remove the reaction from
        unicode - The unicode characters of the emoji
        Returns:
        RestAction
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided unicode is null or empty.
      • removeReactionById

        @CheckReturnValue
        default RestAction<java.lang.Void> removeReactionById​(long messageId,
                                                              java.lang.String unicode)
        Attempts to remove the reaction from a message represented by the specified messageId in this MessageChannel.

        The unicode provided has to be a unicode representation of the emoji that is supposed to be represented by the Reaction.
        To retrieve the characters needed you can use an api or the official discord client by escaping the emoji (\:emoji-name:) and copying the resulting emoji from the sent message.

        This method encodes the provided unicode for you. Do not encode the emoji before providing the unicode.

        The following ErrorResponses are possible:

        Parameters:
        messageId - The messageId to remove the reaction from
        unicode - The unicode characters of the emoji
        Returns:
        RestAction
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided unicode is null or empty.
      • removeReactionById

        @CheckReturnValue
        default RestAction<java.lang.Void> removeReactionById​(java.lang.String messageId,
                                                              Emote emote)
        Attempts to remove the reaction from a message represented by the specified messageId in this MessageChannel.

        An Emote is not the same as an emoji!
        Emotes are custom guild-specific images unlike global unicode emojis!

        The following ErrorResponses are possible:

        Parameters:
        messageId - The messageId to remove the reaction from
        emote - The emote to remove
        Returns:
        RestAction
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided emote is null.
      • editMessageById

        @CheckReturnValue
        default MessageAction editMessageById​(java.lang.String messageId,
                                              java.lang.CharSequence newContent)
        Attempts to edit a message by its id in this MessageChannel. The string provided as newContent must have a length that is greater than 0 and less-than or equal to 2000. This is a Discord message length limitation.

        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 or Group typically due to being kicked or removed, or after Permission.MESSAGE_READ was revoked in the TextChannel
        • UNKNOWN_MESSAGE
          The provided messageId is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
        • UNKNOWN_CHANNEL
          The request was attempted after the channel was deleted.
        Parameters:
        messageId - The id referencing the Message that should be edited
        newContent - The new content for the edited message
        Returns:
        MessageAction
        The modified Message after it has been sent to Discord.
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided newContent is null or empty.
        • If provided newContent length is greater than 2000 characters.
        InsufficientPermissionException - If this is a TextChannel and this account does not have Permission.MESSAGE_READ
      • editMessageById

        @CheckReturnValue
        default MessageAction editMessageById​(long messageId,
                                              java.lang.CharSequence newContent)
        Attempts to edit a message by its id in this MessageChannel. The string provided as newContent must have a length that is greater than 0 and less-than or equal to 2000. This is a Discord message length limitation.

        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 or Group typically due to being kicked or removed, or after Permission.MESSAGE_READ was revoked in the TextChannel
        • UNKNOWN_MESSAGE
          The provided messageId is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
        • UNKNOWN_CHANNEL
          The request was attempted after the channel was deleted.
        Parameters:
        messageId - The id referencing the Message that should be edited
        newContent - The new content for the edited message
        Returns:
        MessageAction
        The modified Message after it has been sent to Discord.
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided newContent is null or empty.
        • If provided newContent length is greater than 2000 characters.
        PermissionException - If this is a TextChannel and this account does not have Permission.MESSAGE_READ
      • editMessageById

        @CheckReturnValue
        default MessageAction editMessageById​(java.lang.String messageId,
                                              Message newContent)
        Attempts to edit a message by its id in this MessageChannel.

        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 or Group typically due to being kicked or removed, or after Permission.MESSAGE_READ was revoked in the TextChannel
        • UNKNOWN_MESSAGE
          The provided messageId is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
        • UNKNOWN_CHANNEL
          The request was attempted after the channel was deleted.
        Parameters:
        messageId - The id referencing the Message that should be edited
        newContent - The new content for the edited message
        Returns:
        MessageAction
        The modified Message after it has been sent to discord
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided newContent is null.
        • If provided Message contains a MessageEmbed which is not sendable
        InsufficientPermissionException - If this is a TextChannel and this account does not have Permission.MESSAGE_READ
      • editMessageById

        @CheckReturnValue
        default MessageAction editMessageById​(long messageId,
                                              Message newContent)
        Attempts to edit a message by its id in this MessageChannel.

        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 or Group typically due to being kicked or removed, or after Permission.MESSAGE_READ was revoked in the TextChannel
        • UNKNOWN_MESSAGE
          The provided messageId is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
        • UNKNOWN_CHANNEL
          The request was attempted after the channel was deleted.
        Parameters:
        messageId - The id referencing the Message that should be edited
        newContent - The new content for the edited message
        Returns:
        MessageAction
        The modified Message after it has been sent to discord
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is not positive.
        • If provided newContent is null.
        • If provided Message contains a MessageEmbed which is not sendable
        InsufficientPermissionException - If this is a TextChannel and this account does not have Permission.MESSAGE_READ
      • editMessageFormatById

        @CheckReturnValue
        default MessageAction editMessageFormatById​(java.lang.String messageId,
                                                    java.lang.String format,
                                                    java.lang.Object... args)
        Attempts to edit a message by its id in this MessageChannel.
        Shortcut for MessageBuilder.appendFormat(String, Object...).

        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 or Group typically due to being kicked or removed, or after Permission.MESSAGE_READ was revoked in the TextChannel
        • UNKNOWN_MESSAGE
          The provided messageId is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
        • UNKNOWN_CHANNEL
          The request was attempted after the channel was deleted.
        Parameters:
        messageId - The id referencing the Message that should be edited
        format - Format String used to generate new Content
        args - The arguments which should be used to format the given format String
        Returns:
        MessageAction
        The modified Message after it has been sent to discord
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided format is null or blank.
        java.lang.IllegalStateException - If the resulting message is either empty or too long to be sent
        InsufficientPermissionException - If this is a TextChannel and this account does not have Permission.MESSAGE_READ
        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.
      • editMessageFormatById

        @CheckReturnValue
        default MessageAction editMessageFormatById​(long messageId,
                                                    java.lang.String format,
                                                    java.lang.Object... args)
        Attempts to edit a message by its id in this MessageChannel.
        Shortcut for MessageBuilder.appendFormat(String, Object...).

        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 or Group typically due to being kicked or removed, or after Permission.MESSAGE_READ was revoked in the TextChannel
        • UNKNOWN_MESSAGE
          The provided messageId is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
        • UNKNOWN_CHANNEL
          The request was attempted after the channel was deleted.
        Parameters:
        messageId - The id referencing the Message that should be edited
        format - Format String used to generate new Content
        args - The arguments which should be used to format the given format String
        Returns:
        MessageAction
        The modified Message after it has been sent to discord
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is not positive.
        • If provided format is null or blank.
        java.lang.IllegalStateException - If the resulting message is either empty or too long to be sent
        InsufficientPermissionException - If this is a TextChannel and this account does not have Permission.MESSAGE_READ
        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.
      • editMessageById

        @CheckReturnValue
        default MessageAction editMessageById​(java.lang.String messageId,
                                              MessageEmbed newEmbed)
        Attempts to edit a message by its id in this MessageChannel.

        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 or Group typically due to being kicked or removed, or after Permission.MESSAGE_READ was revoked in the TextChannel
        • UNKNOWN_MESSAGE
          The provided messageId is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
        • UNKNOWN_CHANNEL
          The request was attempted after the channel was deleted.
        Parameters:
        messageId - The id referencing the Message that should be edited
        newEmbed - The new MessageEmbed for the edited message
        Returns:
        MessageAction
        The modified Message after it has been sent to discord
        Throws:
        java.lang.IllegalArgumentException -
        java.lang.IllegalStateException - If the provided MessageEmbed is null
        InsufficientPermissionException - If this is a TextChannel and this account does not have Permission.MESSAGE_READ or Permission.MESSAGE_WRITE
      • editMessageById

        @CheckReturnValue
        default MessageAction editMessageById​(long messageId,
                                              MessageEmbed newEmbed)
        Attempts to edit a message by its id in this MessageChannel.

        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 or Group typically due to being kicked or removed, or after Permission.MESSAGE_READ was revoked in the TextChannel
        • UNKNOWN_MESSAGE
          The provided messageId is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
        • UNKNOWN_CHANNEL
          The request was attempted after the channel was deleted.
        Parameters:
        messageId - The id referencing the Message that should be edited
        newEmbed - The new MessageEmbed for the edited message
        Returns:
        MessageAction
        The modified Message after it has been sent to discord
        Throws:
        java.lang.IllegalArgumentException -
        java.lang.IllegalStateException - If the provided MessageEmbed is null
        InsufficientPermissionException - If this is a TextChannel and this account does not have Permission.MESSAGE_READ or Permission.MESSAGE_WRITE
      • formatTo

        default void formatTo​(java.util.Formatter formatter,
                              int flags,
                              int width,
                              int precision)
        Specified by:
        formatTo in interface java.util.Formattable