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 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(Entry...) to define placeholders that will be globally available for any Embed.
-
Method Summary
Modifier and TypeMethodDescriptionerrorSource(EmbedDataSource source) Adds a newEmbedDataSourcethat will be used by theDefaultErrorMessageFactoryto load the error messages from.placeholders(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 newEmbedDataSourcethatEmbeds 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
Embedloaded by this API.- Parameters:
placeholders- theMapto get the values from- Returns:
- this instance for fluent interface
-
sources
Adds a newEmbedDataSourcethatEmbeds can be loaded from.- Parameters:
source- theEmbedDataSourceto add- Returns:
- this instance for fluent interface
-
errorSource
Adds a newEmbedDataSourcethat will be used by theDefaultErrorMessageFactoryto load the error messages from.- Parameters:
source- theEmbedDataSourceto load the error embeds from- Returns:
- this instance for fluent interface
-