Class Embed
MessageEmbed
that supports placeholders, localization and easier manipulation of MessageEmbed.Field
s. Can also be
loaded via EmbedDataSource
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Methods for manipulating the fields of anEmbed
. -
Method Summary
Modifier and TypeMethodDescriptionSets the Author of the embed.Sets the Author of the embed.Sets the Author of the embed.build()
Returns aMessageEmbed
just likeEmbedBuilder.build()
, but will also localize this embed based on thelocale(Locale)
andplaceholders
provided.clear()
Resets this builder to default state.color
(int color) Sets the Color of the embed.Sets the Color of the embed.description
(@Nullable CharSequence description) Sets the Description of the embed.fields()
Used to modify the fields of this embed.Sets the Footer of the embed.Sets the Footer of the embed.Sets the Image of the embed.name()
Gets the name of this embed.static Embed
of
(EmbedBuilder embedBuilder, String name, Map<String, @Nullable Object> placeholders, MessageResolver messageResolver) Constructs a newEmbed
.static Embed
of
(DataObject object, String name, Map<String, @Nullable Object> placeholders, MessageResolver messageResolver) Constructs a newEmbed
.placeholders
(Entry... placeholders) Adds all the providedplaceholders
to this embed instance.placeholders
(Map<String, @Nullable Object> placeholders) Adds all the provided placeholders to this embed instance.Sets the Thumbnail of the embed.timestamp
(@Nullable TemporalAccessor accessor) Sets the Timestamp of the embed.Sets the Title of the embed.Sets the Title of the embed.Transforms this embed intoMessageCreateData
.Transforms this embed intoMessageEditData
.Sets the URL of the embed.
-
Method Details
-
of
public static Embed of(EmbedBuilder embedBuilder, String name, Map<String, @Nullable Object> placeholders, MessageResolver messageResolver) Constructs a newEmbed
.- Parameters:
embedBuilder
- theEmbedBuilder
to construct theEmbed
fromname
- the name of this embed used to identify it inEmbedDataSource
splaceholders
- the global placeholders as defined inEmbeds
-
of
public static Embed of(DataObject object, String name, Map<String, @Nullable Object> placeholders, MessageResolver messageResolver) Constructs a newEmbed
.- Parameters:
object
- theDataObject
to construct theEmbed
fromname
- the name of this embed used to identify it inEmbedDataSource
splaceholders
- the global placeholders as defined inEmbeds
-
locale
-
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 theEmbedDataSource
.- Returns:
- the name of this embed
-
title
-
url
Sets the URL of the embed.
The Discord client mostly only uses this property in combination with the title for a clickable Hyperlink.
If multiple embeds in a message use the same URL, the Discord client will merge them into a single embed and aggregate images into a gallery view.
- Returns:
- the builder after the URL has been set
- See Also:
-
title
-
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
Sets the Color of the embed.- Parameters:
color
- The raw rgb value, orRole.DEFAULT_COLOR_RAW
to use no color- Returns:
- this instance for fluent interface
- See Also:
-
color
-
timestamp
Sets the Timestamp of the embed.- Parameters:
accessor
- the temporal accessor of the timestamp- Returns:
- this instance for fluent interface
- See Also:
-
thumbnail
-
image
-
author
-
author
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 embedurl
- the url of the author of the embed- Returns:
- this instance for fluent interface
- See Also:
-
author
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 embedurl
- the url of the author of the embediconUrl
- the url of the icon of the embed- Returns:
- this instance for fluent interface
- See Also:
-
fields
Used to modify the fields of this embed.- Returns:
- this instance for fluent interface
-
clear
Resets this builder to default state.
All parts will be either empty or null after this method has returned.
- Returns:
- The current EmbedBuilder with default values
-
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
Adds all the provided
placeholders
to this embed instance. The values will be replaced whenbuild()
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
- theentries
to add- Returns:
- this instance for fluent interface
-
build
Returns aMessageEmbed
just likeEmbedBuilder.build()
, but will also localize this embed based on thelocale(Locale)
andplaceholders
provided.- Returns:
- the built, sendable
MessageEmbed
-
toMessageCreateData
Transforms this embed intoMessageCreateData
.- Returns:
- the transformed
MessageCreateData
-
toMessageEditData
Transforms this embed intoMessageEditData
.- Returns:
- the transformed
MessageEditData
-