Package me.croabeast.common.discord
Class EmbedObject
java.lang.Object
me.croabeast.common.discord.EmbedObject
Represents a Discord embed message.
The EmbedObject class provides a fluent API for building rich embed messages,
including support for setting the title, description, URL, images, footer, color, and author.
It also supports dynamic token replacement within the text fields.
Example usage:
EmbedObject embed = new EmbedObject("{token}", "Hello, world!")
.setTitle("My Plugin Title")
.setDescription("This is a description with {token} replaced.")
.setUrl("https://example.com")
.setThumbnail("https://example.com/thumbnail.png")
.setImage("https://example.com/image.png")
.setFooter("Footer Text", "https://example.com/footer_icon.png")
.setColor("#FFAA00")
.setAuthor("Author Name", "https://example.com", "https://example.com/author_icon.png");
// Add a field to the embed
embed.addField("Field Name", "Field Value", true);
- Since:
- 1.1
-
Constructor Summary
ConstructorsConstructorDescriptionEmbedObject(String token, String message) Constructs a newEmbedObjectwith the specified token and message. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a field to the embed.Sets the author information for the embed.Sets the color of the embed.setDescription(String text) Sets the description of the embed.Sets the footer text and icon for the embed.Sets the main image URL for the embed.setThumbnail(String url) Sets the thumbnail URL for the embed.Sets the title of the embed.Sets the URL of the embed.
-
Constructor Details
-
EmbedObject
Constructs a newEmbedObjectwith the specified token and message.- Parameters:
token- the token to be replaced in the embed text (must not benull)message- the message that replaces the token (must not benull)
-
-
Method Details
-
setTitle
Sets the title of the embed.- Parameters:
text- the title text- Returns:
- this
EmbedObjectinstance for chaining
-
setDescription
Sets the description of the embed.- Parameters:
text- the description text- Returns:
- this
EmbedObjectinstance for chaining
-
setUrl
Sets the URL of the embed.- Parameters:
text- the URL as a string- Returns:
- this
EmbedObjectinstance for chaining
-
setThumbnail
Sets the thumbnail URL for the embed.- Parameters:
url- the thumbnail URL- Returns:
- this
EmbedObjectinstance for chaining
-
setImage
Sets the main image URL for the embed.- Parameters:
url- the image URL- Returns:
- this
EmbedObjectinstance for chaining
-
setColor
Sets the color of the embed.Attempts to decode the provided color string using
Color.decode(String). If decoding fails, it attempts to retrieve a color by field name fromColor.- Parameters:
color- the color string (e.g., "#FFAA00" or "RED")- Returns:
- this
EmbedObjectinstance for chaining
-
setAuthor
Sets the author information for the embed.- Parameters:
name- the author's nameurl- the author's URLicon- the author's icon URL- Returns:
- this
EmbedObjectinstance for chaining
-
addField
Adds a field to the embed.- Parameters:
name- the name of the fieldvalue- the value of the fieldinLine-trueif the field should be displayed inline;falseotherwise
-