public class EmbedBuilder
extends java.lang.Object
MessageEmbeds.
| Modifier and Type | Field and Description |
|---|---|
static java.util.regex.Pattern |
URL_PATTERN |
static java.lang.String |
ZERO_WIDTH_SPACE |
| Constructor and Description |
|---|
EmbedBuilder()
Creates an EmbedBuilder to be used to creates an embed to send.
|
EmbedBuilder(MessageEmbed embed)
Creates an EmbedBuilder using fields in an existing embed.
|
| Modifier and Type | Method and Description |
|---|---|
EmbedBuilder |
addBlankField(boolean inline)
Adds a blank (empty) Field to the embed.
|
EmbedBuilder |
addField(MessageEmbed.Field field)
Copies the provided Field into a new Field for this builder.
|
EmbedBuilder |
addField(java.lang.String name,
java.lang.String value,
boolean inline)
Adds a Field to the embed.
|
EmbedBuilder |
appendDescription(java.lang.CharSequence description)
Appends to the description of the embed.
|
MessageEmbed |
build()
Returns a
MessageEmbed
that has been checked as being valid for sending. |
EmbedBuilder |
clearFields()
Clears all fields from the embed, such as those created with the
EmbedBuilder(MessageEmbed)
constructor or via the
addField methods. |
java.lang.StringBuilder |
getDescriptionBuilder()
The
StringBuilder used to
build the description for the embed. |
java.util.List<MessageEmbed.Field> |
getFields()
Modifiable list of
MessageEmbed Fields that the builder will
use for build(). |
boolean |
isEmpty()
Checks if the given embed is empty.
|
EmbedBuilder |
setAuthor(java.lang.String name,
java.lang.String url,
java.lang.String iconUrl)
Sets the Author of the embed.
|
EmbedBuilder |
setColor(java.awt.Color color)
Sets the Color of the embed.
|
EmbedBuilder |
setDescription(java.lang.CharSequence description)
Sets the Description of the embed.
|
EmbedBuilder |
setFooter(java.lang.String text,
java.lang.String iconUrl)
Sets the Footer of the embed.
|
EmbedBuilder |
setImage(java.lang.String url)
Sets the Image of the embed.
|
EmbedBuilder |
setThumbnail(java.lang.String url)
Sets the Thumbnail of the embed.
|
EmbedBuilder |
setTimestamp(java.time.temporal.TemporalAccessor temporal)
Sets the Timestamp of the embed.
|
EmbedBuilder |
setTitle(java.lang.String title)
Sets the Title of the embed.
|
EmbedBuilder |
setTitle(java.lang.String title,
java.lang.String url)
Sets the Title of the embed.
|
public static final java.lang.String ZERO_WIDTH_SPACE
public static final java.util.regex.Pattern URL_PATTERN
public EmbedBuilder()
null to the setter method.public EmbedBuilder(MessageEmbed embed)
embed - the existing embedpublic MessageEmbed build()
MessageEmbed
that has been checked as being valid for sending.MessageEmbedjava.lang.IllegalStateException - If the embed is empty. Can be checked with isEmpty().public boolean isEmpty()
public EmbedBuilder setTitle(java.lang.String title)
title - the title of the embedjava.lang.IllegalArgumentException - title is an empty String.title is greater than MessageEmbed.TITLE_MAX_LENGTH.public EmbedBuilder setTitle(java.lang.String title, java.lang.String url)
title - the title of the embedurl - Makes the title into a hyperlink pointed at this url.java.lang.IllegalArgumentException - title is an empty String.title is greater than MessageEmbed.TITLE_MAX_LENGTH.url is longer than MessageEmbed.URL_MAX_LENGTH.url is not a properly formatted http or https url.public java.lang.StringBuilder getDescriptionBuilder()
StringBuilder used to
build the description for the embed.
setDescription(null)public EmbedBuilder setDescription(java.lang.CharSequence description)
description - the description of the embed, null to resetjava.lang.IllegalArgumentException - If the length of description is greater than MessageEmbed.TEXT_MAX_LENGTHpublic EmbedBuilder appendDescription(java.lang.CharSequence description)
description - the string to append to the description of the embedjava.lang.IllegalArgumentException - description String is nulldescription is greater than MessageEmbed.TEXT_MAX_LENGTH.public EmbedBuilder setTimestamp(java.time.temporal.TemporalAccessor temporal)
Hint: You can get the current time using Instant.now() or convert time from a
millisecond representation by using Instant.ofEpochMilli(long);
temporal - the temporal accessor of the timestamppublic EmbedBuilder setColor(java.awt.Color color)
color - The Color of the embed
or null to use no colorpublic EmbedBuilder setThumbnail(java.lang.String url)
url - the url of the thumbnail of the embedjava.lang.IllegalArgumentException - url is longer than MessageEmbed.URL_MAX_LENGTH.url is not a properly formatted http or https url.public EmbedBuilder setImage(java.lang.String url)
url - the url of the image of the embedjava.lang.IllegalArgumentException - url is longer than MessageEmbed.URL_MAX_LENGTH.url is not a properly formatted http or https url.public EmbedBuilder setAuthor(java.lang.String name, java.lang.String url, java.lang.String iconUrl)
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 for the authorjava.lang.IllegalArgumentException - url is longer than MessageEmbed.URL_MAX_LENGTH.url is not a properly formatted http or https url.iconUrl is longer than MessageEmbed.URL_MAX_LENGTH.iconUrl is not a properly formatted http or https url.public EmbedBuilder setFooter(java.lang.String text, java.lang.String iconUrl)
text - the text of the footer of the embed. If this is not set, the footer will not appear in the embed.iconUrl - the url of the icon for the footerjava.lang.IllegalArgumentException - text is longer than MessageEmbed.TEXT_MAX_LENGTH.iconUrl is longer than MessageEmbed.URL_MAX_LENGTH.iconUrl is not a properly formatted http or https url.public EmbedBuilder addField(MessageEmbed.Field field)
addField(String, String, boolean)field - the field object to addpublic EmbedBuilder addField(java.lang.String name, java.lang.String value, boolean inline)
Note: If a blank string is provided to either name or value, the blank string is replaced
with ZERO_WIDTH_SPACE.
name - the name of the Field, displayed in bold above the value.value - the contents of the field.inline - whether or not this field should display inline.java.lang.IllegalArgumentException - name or value is set. Both must be set.name is greater than MessageEmbed.TITLE_MAX_LENGTH.value is greater than MessageEmbed.VALUE_MAX_LENGTH.public EmbedBuilder addBlankField(boolean inline)
inline - whether or not this field should display inlinepublic EmbedBuilder clearFields()
EmbedBuilder(MessageEmbed)
constructor or via the
addField methods.public java.util.List<MessageEmbed.Field> getFields()
MessageEmbed Fields that the builder will
use for build().
List and it will then be applied in the
built MessageEmbed. These fields will be available again through MessageEmbed.getFields().Fields