Class EmbedBuilder

java.lang.Object
com.mewna.catnip.entity.builder.EmbedBuilder

public class EmbedBuilder extends Object
Build a new embed to be used via the REST API.
Since:
9/4/18.
Author:
amy
  • Constructor Details

    • EmbedBuilder

      public EmbedBuilder(Embed embed)
    • EmbedBuilder

      public EmbedBuilder()
  • Method Details

    • timestamp

      @Nonnull @CheckReturnValue public EmbedBuilder timestamp(@Nullable TemporalAccessor temporal)
      Sets the timestamp of the embed. A TemporalAccessor that isn't an OffsetDateTime will be converted to one if possible.
      Parameters:
      temporal - A TemporalAccessor to set.
      Returns:
      Itself.
      Throws:
      DateTimeException - If the TemporalAccessor cannot be converted to an OffsetDateTime.
    • color

      @Nonnull @CheckReturnValue public EmbedBuilder color(@Nullable Color color)
      Set the color of the embed. The alpha bits will be ignored.
      Parameters:
      color - The color to set.
      Returns:
      Itself.
    • color

      @Nonnull @CheckReturnValue public EmbedBuilder color(@Nullable Integer color)
      Set the color of the embed. The alpha bits will be ignored.
      Parameters:
      color - The color to set.
      Returns:
      Itself.
    • footer

      @Nonnull @CheckReturnValue public EmbedBuilder footer(@Nullable String text, @Nullable String iconUrl)
      Add a footer to the embed.
      Parameters:
      text - The text of the footer.
      iconUrl - The URL of the icon in the embed's footer.
      Returns:
      Itself.
    • image

      @Nonnull @CheckReturnValue public EmbedBuilder image(@Nullable String url)
      Set the embed's image.
      Parameters:
      url - The URL of the image.
      Returns:
      Itself.
    • thumbnail

      @Nonnull @CheckReturnValue public EmbedBuilder thumbnail(@Nullable String url)
      Set the embed's thumbnail.
      Parameters:
      url - The URL of the thumbnail image.
      Returns:
      Itself.
    • author

      @Nonnull @CheckReturnValue public EmbedBuilder author(@Nullable String name)
      Set the embed's author.
      Parameters:
      name - The author's name.
      Returns:
      Itself.
    • author

      @Nonnull @CheckReturnValue public EmbedBuilder author(@Nullable String name, @Nullable String url)
      Set the embed's author.
      Parameters:
      name - The author's name.
      url - The URL of the author's page.
      Returns:
      Itself.
    • author

      @Nonnull @CheckReturnValue public EmbedBuilder author(@Nullable String name, @Nullable String url, @Nullable String iconUrl)
      Set the embed's author.
      Parameters:
      name - The author's name.
      url - The URL of the author's page.
      iconUrl - The URL for the author's icon.
      Returns:
      Itself.
    • author

      @Nonnull @CheckReturnValue public EmbedBuilder author(@Nullable Embed.Author author)
      Set the embed's author.
      Parameters:
      author - The new author.
      Returns:
      Itself.
    • field

      @Nonnull @CheckReturnValue public EmbedBuilder field(@Nonnull String name, @Nonnull String value, boolean inline)
      Add a new field to the embed.
      Parameters:
      name - The field's name.
      value - The field's value.
      inline - Whether or not the field should be inline.
      Returns:
      Itself.
    • field

      @Nonnull @CheckReturnValue public EmbedBuilder field(@Nonnull Embed.Field field)
      Add a new field to the embed.
      Parameters:
      field - The field to add.
      Returns:
      Itself.
      Throws:
      IllegalStateException - If more than 25 fields are added.
    • replaceAtIndex

      @Nonnull @CheckReturnValue public EmbedBuilder replaceAtIndex(@Nonnegative int index, @Nonnull String name, @Nonnull String value, boolean inline)
      Replaces the field associated with a specific index with a new field more efficiently.
      Parameters:
      index - The non-negative and under-25 index of the field to replace.
      name - The non-null name of the new field.
      value - The non-null value of the new field.
      inline - Whether or not the field should be inline.
      Returns:
      Itself.
    • replaceAtIndex

      @Nonnull @CheckReturnValue public EmbedBuilder replaceAtIndex(@Nonnegative int index, @Nonnull Embed.Field field)
      Replaces the field associated with a specific index with a new field more efficiently.
      Parameters:
      index - The non-negative and under-25 index of the field to replace.
      field - The non-null field instance.
      Returns:
      Itself.
      Throws:
      IndexOutOfBoundsException - If the field index is smaller than 0, larger than 24 or larger or equal to the amount of fields added.
    • build

      public Embed build()
      Build the embed.
      Returns:
      The new embed.
    • title

      @CheckReturnValue @Nonnull public EmbedBuilder title(@Nullable String title)
      Returns:
      this.
    • description

      @CheckReturnValue @Nonnull public EmbedBuilder description(@Nullable String description)
      Returns:
      this.
    • url

      @CheckReturnValue @Nonnull public EmbedBuilder url(@Nullable String url)
      Returns:
      this.
    • footer

      @CheckReturnValue @Nonnull public EmbedBuilder footer(@Nullable Embed.Footer footer)
      Returns:
      this.