Class EmbedBuilder



  • public class EmbedBuilder
    extends Object
    This class is used to create embeds.
    • Constructor Detail

      • EmbedBuilder

        public EmbedBuilder​()
    • Method Detail

      • getDelegate

        public EmbedBuilderDelegate getDelegate​()
        Gets the delegate used by this embed builder internally.
        Returns:
        The delegate used by this embed builder internally.
      • setTitle

        public EmbedBuilder setTitle​(String title)
        Sets the title of the embed.
        Parameters:
        title - The title of the embed.
        Returns:
        The current instance in order to chain call methods.
      • setDescription

        public EmbedBuilder setDescription​(String description)
        Sets the description of the embed.
        Parameters:
        description - The description of the embed.
        Returns:
        The current instance in order to chain call methods.
      • setUrl

        public EmbedBuilder setUrl​(String url)
        Sets the url of the embed.
        Parameters:
        url - The url of the embed.
        Returns:
        The current instance in order to chain call methods.
      • setTimestampToNow

        public EmbedBuilder setTimestampToNow​()
        Sets the current time as timestamp of the embed.
        Returns:
        The current instance in order to chain call methods.
      • setTimestamp

        public EmbedBuilder setTimestamp​(Instant timestamp)
        Sets the timestamp of the embed.
        Parameters:
        timestamp - The timestamp to set.
        Returns:
        The current instance in order to chain call methods.
      • setColor

        public EmbedBuilder setColor​(Color color)
        Sets the color of the embed.
        Parameters:
        color - The color of the embed.
        Returns:
        The current instance in order to chain call methods.
      • setFooter

        public EmbedBuilder setFooter​(String text)
        Sets the footer of the embed.
        Parameters:
        text - The text of the footer.
        Returns:
        The current instance in order to chain call methods.
      • setFooter

        public EmbedBuilder setFooter​(String text,
                                      String iconUrl)
        Sets the footer of the embed.
        Parameters:
        text - The text of the footer.
        iconUrl - The url of the footer's icon.
        Returns:
        The current instance in order to chain call methods.
      • setFooter

        public EmbedBuilder setFooter​(String text,
                                      Icon icon)
        Sets the footer of the embed.
        Parameters:
        text - The text of the footer.
        icon - The footer's icon.
        Returns:
        The current instance in order to chain call methods.
      • setFooter

        public EmbedBuilder setFooter​(String text,
                                      File icon)
        Sets the footer of the embed.
        Parameters:
        text - The text of the footer.
        icon - The footer's icon.
        Returns:
        The current instance in order to chain call methods.
      • setFooter

        public EmbedBuilder setFooter​(String text,
                                      InputStream icon)
        Sets the footer of the embed. This method assumes the file type is "png"!
        Parameters:
        text - The text of the footer.
        icon - The footer's icon.
        Returns:
        The current instance in order to chain call methods.
      • setFooter

        public EmbedBuilder setFooter​(String text,
                                      InputStream icon,
                                      String fileType)
        Sets the footer of the embed.
        Parameters:
        text - The text of the footer.
        icon - The footer's icon.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • setFooter

        public EmbedBuilder setFooter​(String text,
                                      byte[] icon)
        Sets the footer of the embed. This method assumes the file type is "png"!
        Parameters:
        text - The text of the footer.
        icon - The footer's icon.
        Returns:
        The current instance in order to chain call methods.
      • setFooter

        public EmbedBuilder setFooter​(String text,
                                      byte[] icon,
                                      String fileType)
        Sets the footer of the embed.
        Parameters:
        text - The text of the footer.
        icon - The footer's icon.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • setFooter

        public EmbedBuilder setFooter​(String text,
                                      BufferedImage icon)
        Sets the footer of the embed. This method assumes the file type is "png"!
        Parameters:
        text - The text of the footer.
        icon - The footer's icon.
        Returns:
        The current instance in order to chain call methods.
      • setFooter

        public EmbedBuilder setFooter​(String text,
                                      BufferedImage icon,
                                      String fileType)
        Sets the footer of the embed.
        Parameters:
        text - The text of the footer.
        icon - The footer's icon.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • setImage

        public EmbedBuilder setImage​(String url)
        Sets the image of the embed.
        Parameters:
        url - The url of the image.
        Returns:
        The current instance in order to chain call methods.
      • setImage

        public EmbedBuilder setImage​(Icon image)
        Sets the image of the embed.
        Parameters:
        image - The image.
        Returns:
        The current instance in order to chain call methods.
      • setImage

        public EmbedBuilder setImage​(File image)
        Sets the image of the embed.
        Parameters:
        image - The image.
        Returns:
        The current instance in order to chain call methods.
      • setImage

        public EmbedBuilder setImage​(InputStream image)
        Sets the image of the embed. This method assumes the file type is "png"!
        Parameters:
        image - The image.
        Returns:
        The current instance in order to chain call methods.
      • setImage

        public EmbedBuilder setImage​(InputStream image,
                                     String fileType)
        Sets the image of the embed.
        Parameters:
        image - The image.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • setImage

        public EmbedBuilder setImage​(byte[] image)
        Sets the image of the embed. This method assumes the file type is "png"!
        Parameters:
        image - The image.
        Returns:
        The current instance in order to chain call methods.
      • setImage

        public EmbedBuilder setImage​(byte[] image,
                                     String fileType)
        Sets the image of the embed.
        Parameters:
        image - The image.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • setImage

        public EmbedBuilder setImage​(BufferedImage image)
        Sets the image of the embed. This method assumes the file type is "png"!
        Parameters:
        image - The image.
        Returns:
        The current instance in order to chain call methods.
      • setImage

        public EmbedBuilder setImage​(BufferedImage image,
                                     String fileType)
        Sets the image of the embed.
        Parameters:
        image - The image.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(MessageAuthor author)
        Sets the author of the embed.
        Parameters:
        author - The message author which should be used as author.
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(User author)
        Sets the author of the embed.
        Parameters:
        author - The user which should be used as author.
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(String name)
        Sets the author of the embed.
        Parameters:
        name - The name of the author.
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(String name,
                                      String url,
                                      String iconUrl)
        Sets the author of the embed.
        Parameters:
        name - The name of the author.
        url - The url of the author.
        iconUrl - The url of the author's icon.
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(String name,
                                      String url,
                                      Icon icon)
        Sets the author of the embed.
        Parameters:
        name - The name of the author.
        url - The url of the author.
        icon - The author's icon.
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(String name,
                                      String url,
                                      File icon)
        Sets the author of the embed.
        Parameters:
        name - The name of the author.
        url - The url of the author.
        icon - The author's icon.
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(String name,
                                      String url,
                                      InputStream icon)
        Sets the author of the embed. This method assumes the file type is "png"!
        Parameters:
        name - The name of the author.
        url - The url of the author.
        icon - The author's icon.
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(String name,
                                      String url,
                                      InputStream icon,
                                      String fileType)
        Sets the author of the embed.
        Parameters:
        name - The name of the author.
        url - The url of the author.
        icon - The author's icon.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(String name,
                                      String url,
                                      byte[] icon)
        Sets the author of the embed. This method assumes the file type is "png"!
        Parameters:
        name - The name of the author.
        url - The url of the author.
        icon - The author's icon.
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(String name,
                                      String url,
                                      byte[] icon,
                                      String fileType)
        Sets the author of the embed.
        Parameters:
        name - The name of the author.
        url - The url of the author.
        icon - The author's icon.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(String name,
                                      String url,
                                      BufferedImage icon)
        Sets the author of the embed. This method assumes the file type is "png"!
        Parameters:
        name - The name of the author.
        url - The url of the author.
        icon - The author's icon.
        Returns:
        The current instance in order to chain call methods.
      • setAuthor

        public EmbedBuilder setAuthor​(String name,
                                      String url,
                                      BufferedImage icon,
                                      String fileType)
        Sets the author of the embed.
        Parameters:
        name - The name of the author.
        url - The url of the author.
        icon - The author's icon.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • setThumbnail

        public EmbedBuilder setThumbnail​(String url)
        Sets the thumbnail of the embed.
        Parameters:
        url - The url of the thumbnail.
        Returns:
        The current instance in order to chain call methods.
      • setThumbnail

        public EmbedBuilder setThumbnail​(Icon thumbnail)
        Sets the thumbnail of the embed.
        Parameters:
        thumbnail - The thumbnail.
        Returns:
        The current instance in order to chain call methods.
      • setThumbnail

        public EmbedBuilder setThumbnail​(File thumbnail)
        Sets the thumbnail of the embed.
        Parameters:
        thumbnail - The thumbnail.
        Returns:
        The current instance in order to chain call methods.
      • setThumbnail

        public EmbedBuilder setThumbnail​(InputStream thumbnail)
        Sets the thumbnail of the embed. This method assumes the file type is "png"!
        Parameters:
        thumbnail - The thumbnail.
        Returns:
        The current instance in order to chain call methods.
      • setThumbnail

        public EmbedBuilder setThumbnail​(InputStream thumbnail,
                                         String fileType)
        Sets the thumbnail of the embed.
        Parameters:
        thumbnail - The thumbnail.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • setThumbnail

        public EmbedBuilder setThumbnail​(byte[] thumbnail)
        Sets the thumbnail of the embed. This method assumes the file type is "png"!
        Parameters:
        thumbnail - The thumbnail.
        Returns:
        The current instance in order to chain call methods.
      • setThumbnail

        public EmbedBuilder setThumbnail​(byte[] thumbnail,
                                         String fileType)
        Sets the thumbnail of the embed.
        Parameters:
        thumbnail - The thumbnail.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • setThumbnail

        public EmbedBuilder setThumbnail​(BufferedImage thumbnail)
        Sets the thumbnail of the embed. This method assumes the file type is "png"!
        Parameters:
        thumbnail - The thumbnail.
        Returns:
        The current instance in order to chain call methods.
      • setThumbnail

        public EmbedBuilder setThumbnail​(BufferedImage thumbnail,
                                         String fileType)
        Sets the thumbnail of the embed.
        Parameters:
        thumbnail - The thumbnail.
        fileType - The type of the file, e.g. "png" or "gif".
        Returns:
        The current instance in order to chain call methods.
      • addInlineField

        public EmbedBuilder addInlineField​(String name,
                                           String value)
        Adds an inline field to the embed.
        Parameters:
        name - The name of the field.
        value - The value of the field.
        Returns:
        The current instance in order to chain call methods.
      • addField

        public EmbedBuilder addField​(String name,
                                     String value)
        Adds a non-inline field to the embed.
        Parameters:
        name - The name of the field.
        value - The value of the field.
        Returns:
        The current instance in order to chain call methods.
      • addField

        public EmbedBuilder addField​(String name,
                                     String value,
                                     boolean inline)
        Adds a field to the embed.
        Parameters:
        name - The name of the field.
        value - The value of the field.
        inline - Whether the field should be inline or not.
        Returns:
        The current instance in order to chain call methods.
      • updateFields

        public EmbedBuilder updateFields​(Predicate<EmbedField> predicate,
                                         Consumer<EditableEmbedField> updater)
        Updates all fields of the embed that satisfy the given predicate using the given updater.
        Parameters:
        predicate - The predicate that fields have to satisfy to get updated.
        updater - The updater for the fields; the EditableEmbedField is only valid during the run of the updater; any try to save it in a variable and reuse it later after this method call will fail with exceptions.
        Returns:
        The current instance in order to chain call methods.
      • updateAllFields

        public EmbedBuilder updateAllFields​(Consumer<EditableEmbedField> updater)
        Updates all fields of the embed using the given updater.
        Parameters:
        updater - The updater for the fields; the EditableEmbedField is only valid during the run of the updater; any try to save it in a variable and reuse it later after this method call will fail with exceptions.
        Returns:
        The current instance in order to chain call methods.
      • removeFields

        public EmbedBuilder removeFields​(Predicate<EmbedField> predicate)
        Removes all fields of the embed that satisfy the given predicate.
        Parameters:
        predicate - The predicate that fields have to satisfy to get removed.
        Returns:
        The current instance in order to chain call methods.
      • removeAllFields

        public EmbedBuilder removeAllFields​()
        Removes all fields of the embed.
        Returns:
        The current instance in order to chain call methods.
      • requiresAttachments

        public boolean requiresAttachments​()
        Checks if this embed requires any attachments.
        Returns:
        Whether the embed requires attachments or not.