Interface EmbedConfig

All Known Implementing Classes:
Embeds.Configuration

public interface EmbedConfig

Builder for configuring the Embed API of JDA-Commands.

Embed Sources

Use sources(EmbedDataSource...) to add an EmbedDataSource that Embeds can be loaded from. You can have multiple EmbedDataSources.

Use EmbedDataSource.file(Path) to load embeds from a JSON file. The file must contain a single JSON object that contains all embeds that can be loaded as child objects. Every embed must have a unique name, the embed object must follow the Discord API format.

Example

{
   "example": {
      "title": "Greetings",
      "description": "Hello World!"
   }
}

Localization

The Embed API supports localization via the I18n class. The embed fields can either contain a localization key a direct localization message in a format supported by the Localizer implementation.

For the default Localizer implementation, which uses Fluava, this could look like this:

{
   "example": {
      "title": "example-title", // localization key
      "description": "Hello {$user}!" // localization message
   }
}

Global Placeholders

Use placeholders(I18n.Entry...) to define placeholders that will be globally available for any Embed.

  • Method Details

    • placeholders

      EmbedConfig placeholders(I18n.Entry... placeholders)
      Adds one or more new global placeholders. Global placeholders will be available for any Embed loaded by this API.
      Parameters:
      placeholders - the entries to add
      Returns:
      this instance for fluent interface
    • placeholders

      EmbedConfig placeholders(Map<String,Object> placeholders)

      Adds global placeholders with the values of the given map, where the key of the map represents the name of the placeholder and the value of the map the value to replace the placeholder with.

      Global placeholders will be available for any Embed loaded by this API.

      Parameters:
      placeholders - the Map to get the values from
      Returns:
      this instance for fluent interface
    • sources

      EmbedConfig sources(EmbedDataSource... source)
      Adds a new EmbedDataSource that Embeds can be loaded from.
      Parameters:
      source - the EmbedDataSource to add
      Returns:
      this instance for fluent interface
    • errorSource

      EmbedConfig errorSource(EmbedDataSource source)
      Adds a new EmbedDataSource that will be used by the DefaultErrorMessageFactory to load the error messages from.
      Parameters:
      source - the EmbedDataSource to load the error embeds from
      Returns:
      this instance for fluent interface