Interface EmbedConfig
- All Known Implementing Classes:
Embeds.Configuration
Builder for configuring the Embed API of JDA-Commands.
Embed Sources
Use sources(EmbedDataSource...)
to add an EmbedDataSource
that Embed
s can be loaded from. You can have
multiple EmbedDataSource
s.
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 Summary
Modifier and TypeMethodDescriptionerrorSource
(EmbedDataSource source) Adds a newEmbedDataSource
that will be used by theDefaultErrorMessageFactory
to load the error messages from.placeholders
(I18n.Entry... placeholders) Adds one or more new global placeholders.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.sources
(EmbedDataSource... source) Adds a newEmbedDataSource
thatEmbed
s can be loaded from.
-
Method Details
-
placeholders
-
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
- theMap
to get the values from- Returns:
- this instance for fluent interface
-
sources
Adds a newEmbedDataSource
thatEmbed
s can be loaded from.- Parameters:
source
- theEmbedDataSource
to add- Returns:
- this instance for fluent interface
-
errorSource
Adds a newEmbedDataSource
that will be used by theDefaultErrorMessageFactory
to load the error messages from.- Parameters:
source
- theEmbedDataSource
to load the error embeds from- Returns:
- this instance for fluent interface
-