Class MessageUpdater


  • public class MessageUpdater
    extends java.lang.Object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T addActionRow​(LowLevelComponent... components)
      Add multiple low level components, wrapped in an ActionRow, to the message.
      T addAttachment​(byte[] bytes, java.lang.String fileName)
      Adds an attachment to the message.
      T addAttachment​(byte[] bytes, java.lang.String fileName, java.lang.String description)
      Adds an attachment to the message.
      T addAttachment​(java.awt.image.BufferedImage image, java.lang.String fileName)
      Adds an attachment to the message.
      T addAttachment​(java.awt.image.BufferedImage image, java.lang.String fileName, java.lang.String description)
      Adds an attachment to the message.
      T addAttachment​(java.io.File file)
      Adds an attachment to the message.
      T addAttachment​(java.io.File file, java.lang.String description)
      Adds an attachment to the message.
      T addAttachment​(java.io.InputStream stream, java.lang.String fileName)
      Adds an attachment to the message.
      T addAttachment​(java.io.InputStream stream, java.lang.String fileName, java.lang.String description)
      Adds an attachment to the message.
      T addAttachment​(java.net.URL url)
      Adds an attachment to the message.
      T addAttachment​(java.net.URL url, java.lang.String description)
      Adds an attachment to the message.
      T addAttachment​(Icon icon)
      Adds an attachment to the message.
      T addAttachment​(Icon icon, java.lang.String description)
      Adds an attachment to the message.
      T addAttachmentAsSpoiler​(byte[] bytes, java.lang.String fileName)
      Adds an attachment to the message and marks it as spoiler.
      T addAttachmentAsSpoiler​(byte[] bytes, java.lang.String fileName, java.lang.String description)
      Adds an attachment to the message and marks it as spoiler.
      T addAttachmentAsSpoiler​(java.awt.image.BufferedImage image, java.lang.String fileName)
      Adds an attachment to the message and marks it as spoiler.
      T addAttachmentAsSpoiler​(java.awt.image.BufferedImage image, java.lang.String fileName, java.lang.String description)
      Adds an attachment to the message and marks it as spoiler.
      T addAttachmentAsSpoiler​(java.io.File file)
      Adds an attachment to the message and marks it as spoiler.
      T addAttachmentAsSpoiler​(java.io.File file, java.lang.String description)
      Adds an attachment to the message and marks it as spoiler.
      T addAttachmentAsSpoiler​(java.io.InputStream stream, java.lang.String fileName)
      Adds an attachment to the message and marks it as spoiler.
      T addAttachmentAsSpoiler​(java.io.InputStream stream, java.lang.String fileName, java.lang.String description)
      Adds an attachment to the message and marks it as spoiler.
      T addAttachmentAsSpoiler​(java.net.URL url)
      Adds an attachment to the message and marks it as spoiler.
      T addAttachmentAsSpoiler​(java.net.URL url, java.lang.String description)
      Adds an attachment to the message and marks it as spoiler.
      T addAttachmentAsSpoiler​(Icon icon)
      Adds an attachment to the message and marks it as spoiler.
      T addAttachmentAsSpoiler​(Icon icon, java.lang.String description)
      Adds an attachment to the message and marks it as spoiler.
      T addComponents​(HighLevelComponent... components)
      Add multiple high level components to the message.
      T addEmbed​(EmbedBuilder embed)
      Adds an embed to the message.
      T addEmbeds​(java.util.List<EmbedBuilder> embeds)
      Adds the embeds to the message.
      T addEmbeds​(EmbedBuilder... embeds)
      Adds the embeds to the message.
      T append​(java.lang.Object object)
      Appends the string representation of the object (calling String.valueOf(Object) method) to the message.
      T append​(java.lang.String message, MessageDecoration... decorations)
      Appends a sting with or without decoration to the message.
      T append​(Mentionable entity)
      Appends a mentionable entity (usually a user or channel) to the message.
      T appendCode​(java.lang.String language, java.lang.String code)
      Appends code to the message.
      T appendNewLine()
      Appends a new line to the message.
      T appendTimestamp​(long epochSeconds)
      Appends a timestamp to the message with the default timestamp style TimestampStyle.SHORT_DATE_TIME.
      T appendTimestamp​(long epochSeconds, TimestampStyle timestampStyle)
      Appends a timestamp to the message.
      T appendTimestamp​(java.time.Instant instant)
      Appends a timestamp to the message with the default timestamp style TimestampStyle.SHORT_DATE_TIME.
      T appendTimestamp​(java.time.Instant instant, TimestampStyle timestampStyle)
      Appends a timestamp to the message.
      java.util.concurrent.CompletableFuture<Message> applyChanges()
      Edits the message, updating all fields that have been changed by a method call.
      java.lang.StringBuilder getStringBuilder()
      Gets the StringBuilder which is used to build the message.
      T removeAllComponents()
      Remove all high-level components from the message.
      T removeAllEmbeds()
      Removes all embeds from the message.
      T removeContent()
      Removes the content of the message.
      T removeEmbed​(EmbedBuilder embed)
      Removes the embed from the message.
      T removeEmbeds​(EmbedBuilder... embeds)
      Removes the embeds from the message.
      MessageUpdater removeExistingAttachment​(Attachment attachment)
      Removes an attachment from the message.
      MessageUpdater removeExistingAttachments()
      Removes all the attachments from the message.
      MessageUpdater removeExistingAttachments​(java.util.Collection<Attachment> attachments)
      Removes multiple attachments from the message.
      MessageUpdater removeExistingAttachments​(Attachment... attachments)
      Removes multiple attachments from the message.
      java.util.concurrent.CompletableFuture<Message> replaceMessage()
      Edits the message, updating all fields.
      T setAllowedMentions​(AllowedMentions allowedMentions)
      Controls who will be mentioned if mentions exist in the message.
      T setContent​(java.lang.String content)
      Sets the content of the message.
      T setEmbed​(EmbedBuilder embed)
      Sets the embed of the message (overrides all existing embeds).
      T setEmbeds​(java.util.List<EmbedBuilder> embeds)
      Sets multiple embeds of the message (overrides all existing embeds).
      T setEmbeds​(EmbedBuilder... embeds)
      Sets multiple embeds of the message (overrides all existing embeds).
      T setNonce​(java.lang.String nonce)
      Sets the nonce of the message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MessageUpdater

        public MessageUpdater​(Message m)
        Class constructor.
        Parameters:
        m - The message to update.
    • Method Detail

      • applyChanges

        public java.util.concurrent.CompletableFuture<Message> applyChanges()
        Edits the message, updating all fields that have been changed by a method call. For example, the content of the message will only be patched if you called a method on this updater that affects the content.
        Returns:
        The edited message.
      • replaceMessage

        public java.util.concurrent.CompletableFuture<Message> replaceMessage()
        Edits the message, updating all fields. Fields that have not been set will be dropped and removed from the actual message on Discord.
        Returns:
        The edited message.
      • removeExistingAttachment

        public MessageUpdater removeExistingAttachment​(Attachment attachment)
        Removes an attachment from the message.
        Parameters:
        attachment - The attachment to remove.
        Returns:
        The current instance in order to chain call methods.
      • removeExistingAttachments

        public MessageUpdater removeExistingAttachments()
        Removes all the attachments from the message.
        Returns:
        The current instance in order to chain call methods.
      • removeExistingAttachments

        public MessageUpdater removeExistingAttachments​(Attachment... attachments)
        Removes multiple attachments from the message.
        Parameters:
        attachments - The attachments to remove.
        Returns:
        The current instance in order to chain call methods.
      • removeExistingAttachments

        public MessageUpdater removeExistingAttachments​(java.util.Collection<Attachment> attachments)
        Removes multiple attachments from the message.
        Parameters:
        attachments - The attachments to remove.
        Returns:
        The current instance in order to chain call methods.
      • addComponents

        public T addComponents​(HighLevelComponent... components)
        Add multiple high level components to the message.
        Parameters:
        components - The high level components.
        Returns:
        The current instance in order to chain call methods.
      • addActionRow

        public T addActionRow​(LowLevelComponent... components)
        Add multiple low level components, wrapped in an ActionRow, to the message.
        Parameters:
        components - The low level components.
        Returns:
        The current instance in order to chain call methods.
      • appendCode

        public T appendCode​(java.lang.String language,
                            java.lang.String code)
        Appends code to the message.
        Parameters:
        language - The language, e.g. "java".
        code - The code.
        Returns:
        The current instance in order to chain call methods.
      • appendTimestamp

        public T appendTimestamp​(long epochSeconds)
        Appends a timestamp to the message with the default timestamp style TimestampStyle.SHORT_DATE_TIME.
        Parameters:
        epochSeconds - The epoch time in seconds.
        Returns:
        The current instance in order to chain call methods.
      • appendTimestamp

        public T appendTimestamp​(java.time.Instant instant)
        Appends a timestamp to the message with the default timestamp style TimestampStyle.SHORT_DATE_TIME.
        Parameters:
        instant - The instant for the displaying timestamp.
        Returns:
        The current instance in order to chain call methods.
      • appendTimestamp

        public T appendTimestamp​(long epochSeconds,
                                 TimestampStyle timestampStyle)
        Appends a timestamp to the message.
        Parameters:
        epochSeconds - The epoch time in seconds.
        timestampStyle - The displayed timestamp style.
        Returns:
        The current instance in order to chain call methods.
      • appendTimestamp

        public T appendTimestamp​(java.time.Instant instant,
                                 TimestampStyle timestampStyle)
        Appends a timestamp to the message.
        Parameters:
        instant - The instant for the displaying timestamp.
        timestampStyle - The displayed timestamp style.
        Returns:
        The current instance in order to chain call methods.
      • append

        public T append​(java.lang.String message,
                        MessageDecoration... decorations)
        Appends a sting with or without decoration to the message.
        Parameters:
        message - The string to append.
        decorations - The decorations of the string.
        Returns:
        The current instance in order to chain call methods.
      • append

        public T append​(Mentionable entity)
        Appends a mentionable entity (usually a user or channel) to the message.
        Parameters:
        entity - The entity to mention.
        Returns:
        The current instance in order to chain call methods.
      • append

        public T append​(java.lang.Object object)
        Appends the string representation of the object (calling String.valueOf(Object) method) to the message.
        Parameters:
        object - The object to append.
        Returns:
        The current instance in order to chain call methods.
        See Also:
        StringBuilder.append(Object)
      • appendNewLine

        public T appendNewLine()
        Appends a new line to the message.
        Returns:
        The current instance in order to chain call methods.
      • setContent

        public T setContent​(java.lang.String content)
        Sets the content of the message. This method overwrites all previous content changes (using append(String, MessageDecoration...) for example).
        Parameters:
        content - The new content of the message.
        Returns:
        The current instance in order to chain call methods.
      • removeContent

        public T removeContent()
        Removes the content of the message. This method overwrites all previous content changes (using append(String, MessageDecoration...) for example).
        Returns:
        The current instance in order to chain call methods.
      • setEmbed

        public T setEmbed​(EmbedBuilder embed)
        Sets the embed of the message (overrides all existing embeds).
        Parameters:
        embed - The embed to set.
        Returns:
        The current instance in order to chain call methods.
      • setEmbeds

        public T setEmbeds​(EmbedBuilder... embeds)
        Sets multiple embeds of the message (overrides all existing embeds).
        Parameters:
        embeds - The embed to set.
        Returns:
        The current instance in order to chain call methods.
      • setEmbeds

        public T setEmbeds​(java.util.List<EmbedBuilder> embeds)
        Sets multiple embeds of the message (overrides all existing embeds).
        Parameters:
        embeds - The embed to set.
        Returns:
        The current instance in order to chain call methods.
      • addEmbed

        public T addEmbed​(EmbedBuilder embed)
        Adds an embed to the message.
        Parameters:
        embed - The embed to add.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(java.awt.image.BufferedImage image,
                               java.lang.String fileName)
        Adds an attachment to the message.
        Parameters:
        image - The image to add as an attachment.
        fileName - The file name of the image.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(java.awt.image.BufferedImage image,
                               java.lang.String fileName,
                               java.lang.String description)
        Adds an attachment to the message.
        Parameters:
        image - The image to add as an attachment.
        fileName - The file name of the image.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(java.io.File file)
        Adds an attachment to the message.
        Parameters:
        file - The file to add as an attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(java.io.File file,
                               java.lang.String description)
        Adds an attachment to the message.
        Parameters:
        file - The file to add as an attachment.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(Icon icon)
        Adds an attachment to the message.
        Parameters:
        icon - The icon to add as an attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(Icon icon,
                               java.lang.String description)
        Adds an attachment to the message.
        Parameters:
        icon - The icon to add as an attachment.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(java.net.URL url)
        Adds an attachment to the message.
        Parameters:
        url - The url of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(java.net.URL url,
                               java.lang.String description)
        Adds an attachment to the message.
        Parameters:
        url - The url of the attachment.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(byte[] bytes,
                               java.lang.String fileName)
        Adds an attachment to the message.
        Parameters:
        bytes - The bytes of the file.
        fileName - The name of the file.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(byte[] bytes,
                               java.lang.String fileName,
                               java.lang.String description)
        Adds an attachment to the message.
        Parameters:
        bytes - The bytes of the file.
        fileName - The name of the file.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(java.io.InputStream stream,
                               java.lang.String fileName)
        Adds an attachment to the message.
        Parameters:
        stream - The stream of the file.
        fileName - The name of the file.
        Returns:
        The current instance in order to chain call methods.
      • addAttachment

        public T addAttachment​(java.io.InputStream stream,
                               java.lang.String fileName,
                               java.lang.String description)
        Adds an attachment to the message.
        Parameters:
        stream - The stream of the file.
        fileName - The name of the file.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(java.awt.image.BufferedImage image,
                                        java.lang.String fileName)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        image - The image to add as an attachment.
        fileName - The file name of the image.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(java.awt.image.BufferedImage image,
                                        java.lang.String fileName,
                                        java.lang.String description)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        image - The image to add as an attachment.
        fileName - The file name of the image.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(java.io.File file)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        file - The file to add as an attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(java.io.File file,
                                        java.lang.String description)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        file - The file to add as an attachment.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(Icon icon)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        icon - The icon to add as an attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(Icon icon,
                                        java.lang.String description)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        icon - The icon to add as an attachment.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(java.net.URL url)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        url - The url of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(java.net.URL url,
                                        java.lang.String description)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        url - The url of the attachment.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(byte[] bytes,
                                        java.lang.String fileName)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        bytes - The bytes of the file.
        fileName - The name of the file.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(byte[] bytes,
                                        java.lang.String fileName,
                                        java.lang.String description)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        bytes - The bytes of the file.
        fileName - The name of the file.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(java.io.InputStream stream,
                                        java.lang.String fileName)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        stream - The stream of the file.
        fileName - The name of the file.
        Returns:
        The current instance in order to chain call methods.
      • addAttachmentAsSpoiler

        public T addAttachmentAsSpoiler​(java.io.InputStream stream,
                                        java.lang.String fileName,
                                        java.lang.String description)
        Adds an attachment to the message and marks it as spoiler.
        Parameters:
        stream - The stream of the file.
        fileName - The name of the file.
        description - The description of the attachment.
        Returns:
        The current instance in order to chain call methods.
      • setAllowedMentions

        public T setAllowedMentions​(AllowedMentions allowedMentions)
        Controls who will be mentioned if mentions exist in the message.
        Parameters:
        allowedMentions - The mention object.
        Returns:
        The current instance in order to chain call methods.
      • removeAllComponents

        public T removeAllComponents()
        Remove all high-level components from the message.
        Returns:
        The current instance in order to chain call methods.
      • addEmbeds

        public T addEmbeds​(EmbedBuilder... embeds)
        Adds the embeds to the message.
        Parameters:
        embeds - The embeds to add.
        Returns:
        The current instance in order to chain call methods.
      • addEmbeds

        public T addEmbeds​(java.util.List<EmbedBuilder> embeds)
        Adds the embeds to the message.
        Parameters:
        embeds - The embeds to add.
        Returns:
        The current instance in order to chain call methods.
      • removeEmbed

        public T removeEmbed​(EmbedBuilder embed)
        Removes the embed from the message.
        Parameters:
        embed - The embed to remove.
        Returns:
        The current instance in order to chain call methods.
      • removeEmbeds

        public T removeEmbeds​(EmbedBuilder... embeds)
        Removes the embeds from the message.
        Parameters:
        embeds - The embeds to remove.
        Returns:
        The current instance in order to chain call methods.
      • removeAllEmbeds

        public T removeAllEmbeds()
        Removes all embeds from the message.
        Returns:
        The current instance in order to chain call methods.
      • setNonce

        public T setNonce​(java.lang.String nonce)
        Sets the nonce of the message.
        Parameters:
        nonce - The nonce to set.
        Returns:
        The current instance in order to chain call methods.
      • getStringBuilder

        public java.lang.StringBuilder getStringBuilder()
        Gets the StringBuilder which is used to build the message.
        Returns:
        The StringBuilder which is used to build the message.