Class Embed

java.lang.Object
net.dv8tion.jda.api.EmbedBuilder
com.github.kaktushose.jda.commands.embeds.Embed

public class Embed extends EmbedBuilder
Subclass of EmbedBuilder that supports placeholders and easier manipulation of fields.
  • Constructor Details

  • Method Details

    • locale

      public Embed locale(Locale locale)
      Sets the Locale this Embed will be localized with.
      Parameters:
      locale - the Locale to use for localization
      Returns:
      this instance for fluent interface
      See Also:
    • name

      public String name()
      Gets the name of this embed. This isn't a field that get displayed but only the name this embed is referenced by in the EmbedDataSource.
      Returns:
      the name of this embed
    • title

      public Embed title(@Nullable String title)
      Sets the Title of the embed.
      Parameters:
      title - the title of the embed
      Returns:
      this instance for fluent interface
      See Also:
    • title

      public Embed title(@Nullable String title, @Nullable String url)
      Sets the Title of the embed.
      Parameters:
      title - the title of the embed
      url - Makes the title into a hyperlink pointed at this url.
      Returns:
      this instance for fluent interface
      See Also:
    • description

      public Embed description(@Nullable CharSequence description)
      Sets the Description of the embed.
      Parameters:
      description - the description of the embed, null to reset
      Returns:
      this instance for fluent interface
      See Also:
    • color

      public Embed color(int color)
      Sets the Color of the embed.
      Parameters:
      color - The raw rgb value, or Role.DEFAULT_COLOR_RAW to use no color
      Returns:
      this instance for fluent interface
      See Also:
    • color

      public Embed color(@Nullable Color color)
      Sets the Color of the embed.
      Parameters:
      color - The Color of the embed or null to use no color
      Returns:
      this instance for fluent interface
      See Also:
    • timestamp

      public Embed timestamp(@Nullable TemporalAccessor accessor)
      Sets the Timestamp of the embed.
      Parameters:
      accessor - the temporal accessor of the timestamp
      Returns:
      this instance for fluent interface
      See Also:
    • footer

      public Embed footer(@Nullable String footer)
      Sets the Footer of the embed.
      Parameters:
      footer - the text of the footer of the embed. If this is not set or set to null, the footer will not appear in the embed.
      Returns:
      this instance for fluent interface
      See Also:
    • footer

      public Embed footer(@Nullable String footer, @Nullable String iconUrl)
      Sets the Footer of the embed.
      Parameters:
      footer - the text of the footer of the embed. If this is not set or set to null, the footer will not appear in the embed.
      iconUrl - the url of the icon for the footer
      Returns:
      this instance for fluent interface
      See Also:
    • thumbnail

      public Embed thumbnail(@Nullable String url)
      Sets the Thumbnail of the embed.
      Parameters:
      url - the url of the thumbnail of the embed
      Returns:
      this instance for fluent interface
      See Also:
    • image

      public Embed image(@Nullable String url)
      Sets the Image of the embed.
      Parameters:
      url - the url of the image of the embed
      Returns:
      this instance for fluent interface
      See Also:
    • author

      public Embed author(@Nullable String name)
      Sets the Author of the embed.
      Parameters:
      name - the name of the author of the embed. If this is not set, the author will not appear in the embed
      Returns:
      this instance for fluent interface
      See Also:
    • author

      public Embed author(@Nullable String name, @Nullable String url)
      Sets the Author of the embed.
      Parameters:
      name - the name of the author of the embed. If this is not set, the author will not appear in the embed
      url - the url of the author of the embed
      Returns:
      this instance for fluent interface
      See Also:
    • author

      public Embed author(@Nullable String name, @Nullable String url, @Nullable String iconUrl)
      Sets the Author of the embed.
      Parameters:
      name - the name of the author of the embed. If this is not set, the author will not appear in the embed
      url - the url of the author of the embed
      iconUrl - the url of the icon of the embed
      Returns:
      this instance for fluent interface
      See Also:
    • fields

      public Embed.Fields fields()
      Used to modify the fields of this embed.
      Returns:
      this instance for fluent interface
    • addField

      public Embed addField(String name, String value)
      Adds a Field to the embed that isn't inlined.
      Parameters:
      name - the name of the Field, displayed in bold above the value.
      value - the contents of the field.
      Returns:
      this instance for fluent interface
    • placeholders

      public Embed placeholders(Map<String,Object> placeholders)

      Adds all the provided placeholders to this embed instance. The values will be replaced when build() is called.

      Existing entries with the same keys will be overwritten.

      Internally this uses the localization system, thus placeholders are limited by the used Localizer implementation

      Parameters:
      placeholders - a map of placeholder names to their corresponding values
      Returns:
      this instance for fluent interface
    • placeholders

      public Embed placeholders(I18n.Entry... placeholders)

      Adds all the provided placeholders to this embed instance. The values will be replaced when build() is called.

      Existing entries with the same keys will be overwritten.

      Internally this uses the localization system, thus placeholders are limited by the used Localizer implementation

      Parameters:
      placeholders - the entries to add
      Returns:
      this instance for fluent interface
    • build

      public MessageEmbed build()
      Returns a MessageEmbed just like EmbedBuilder.build(), but will also localize this embed based on the locale(Locale) and placeholders provided.
      Overrides:
      build in class EmbedBuilder
      Returns:
      the built, sendable MessageEmbed
    • toMessageCreateData

      public MessageCreateData toMessageCreateData()
      Transforms this embed into MessageCreateData.
      Returns:
      the transformed MessageCreateData
    • toMessageEditData

      public MessageEditData toMessageEditData()
      Transforms this embed into MessageEditData.
      Returns:
      the transformed MessageEditData