Class WebhookEmbedBuilder
- java.lang.Object
-
- club.minnced.discord.webhook.send.WebhookEmbedBuilder
-
public class WebhookEmbedBuilder extends Object
Builder for aWebhookEmbedinstance.
-
-
Constructor Summary
Constructors Constructor Description WebhookEmbedBuilder()Creates an empty builderWebhookEmbedBuilder(@Nullable WebhookEmbed embed)Creates a builder with predefined settings from the providedWebhookEmbedinstance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description @NotNull WebhookEmbedBuilderaddField(WebhookEmbed.EmbedField field)Adds anWebhookEmbed.EmbedFieldto this embed.@NotNull WebhookEmbedbuild()Builds a newWebhookEmbedinstance from the current settings.static @NotNull WebhookEmbedBuilderfromD4J(@NotNull discord4j.core.spec.EmbedCreateSpec spec)Converts a Discord4JEmbedCreateSpecinto a compatible WebhookEmbedBuilder.static @NotNull WebhookEmbedBuilderfromD4J(@NotNull discord4j.discordjson.json.EmbedData data)Converts a Discord4JEmbedDatainto a compatible WebhookEmbedBuilder.static @NotNull WebhookEmbedBuilderfromD4J(@NotNull Consumer<? super discord4j.core.spec.EmbedCreateSpec> callback)Deprecated.Replace withfromD4J(EmbedCreateSpec)static @NotNull WebhookEmbedBuilderfromJavacord(org.javacord.api.entity.message.embed.Embed embed)Converts a JavacordEmbedinto a compatible WebhookEmbedBuilder.static @NotNull WebhookEmbedBuilderfromJDA(net.dv8tion.jda.api.entities.MessageEmbed embed)Converts a JDAMessageEmbedinto a compatible WebhookEmbedBuilder.booleanisEmpty()Whether this embed is currently empty.voidreset()Resets the builder to its default state@NotNull WebhookEmbedBuildersetAuthor(WebhookEmbed.EmbedAuthor author)The author for this embed.@NotNull WebhookEmbedBuildersetColor(@Nullable Integer color)The rgb color to use for the line left to the resulting embed@NotNull WebhookEmbedBuildersetDescription(@Nullable String description)The description of the embed, this is the default text used in most embeds.@NotNull WebhookEmbedBuildersetFooter(WebhookEmbed.EmbedFooter footer)The footer for this embed.@NotNull WebhookEmbedBuildersetImageUrl(@Nullable String imageUrl)The image url for this embed.@NotNull WebhookEmbedBuildersetThumbnailUrl(@Nullable String thumbnailUrl)The thumbnail url for this embed.@NotNull WebhookEmbedBuildersetTimestamp(@Nullable TemporalAccessor timestamp)The timestamp for the resulting embed.@NotNull WebhookEmbedBuildersetTitle(WebhookEmbed.EmbedTitle title)The title for this embed.
-
-
-
Constructor Detail
-
WebhookEmbedBuilder
public WebhookEmbedBuilder()
Creates an empty builder
-
WebhookEmbedBuilder
public WebhookEmbedBuilder(@Nullable @Nullable WebhookEmbed embed)Creates a builder with predefined settings from the providedWebhookEmbedinstance- Parameters:
embed- The (nullable) embed to copy
-
-
Method Detail
-
reset
public void reset()
Resets the builder to its default state
-
setTimestamp
@NotNull public @NotNull WebhookEmbedBuilder setTimestamp(@Nullable @Nullable TemporalAccessor timestamp)
The timestamp for the resulting embed.
Usually used in combination withOffsetDateTime.- Parameters:
timestamp- The timestamp- Returns:
- The current builder for chaining convenience
- Throws:
DateTimeException- If unable to convert to anOffsetDateTime
-
setColor
@NotNull public @NotNull WebhookEmbedBuilder setColor(@Nullable @Nullable Integer color)
The rgb color to use for the line left to the resulting embed- Parameters:
color- The (nullable) color to use- Returns:
- The current builder for chaining convenience
-
setDescription
@NotNull public @NotNull WebhookEmbedBuilder setDescription(@Nullable @Nullable String description)
The description of the embed, this is the default text used in most embeds. It is displayed below author and title and above fields and image.- Parameters:
description- The (nullable) description to use- Returns:
- The current builder for chaining convenience
-
setThumbnailUrl
@NotNull public @NotNull WebhookEmbedBuilder setThumbnailUrl(@Nullable @Nullable String thumbnailUrl)
The thumbnail url for this embed.
This is displayed as small image to the right side of the description.- Parameters:
thumbnailUrl- The (nullable) thumbnail url- Returns:
- The current builder for chaining convenience
-
setImageUrl
@NotNull public @NotNull WebhookEmbedBuilder setImageUrl(@Nullable @Nullable String imageUrl)
The image url for this embed.
This is displayed below the description.- Parameters:
imageUrl- The (nullable) image url- Returns:
- The current builder for chaining convenience
-
setFooter
@NotNull public @NotNull WebhookEmbedBuilder setFooter(@Nullable WebhookEmbed.EmbedFooter footer)
The footer for this embed.
This is displayed at the very bottom of the embed next to the timestamp.- Parameters:
footer- The (nullable)WebhookEmbed.EmbedFooter- Returns:
- The current builder for chaining convenience
-
setTitle
@NotNull public @NotNull WebhookEmbedBuilder setTitle(@Nullable WebhookEmbed.EmbedTitle title)
The title for this embed.
This is displayed below the author and above everything else.- Parameters:
title- The (nullable)WebhookEmbed.EmbedTitle- Returns:
- The current builder for chaining convenience
-
setAuthor
@NotNull public @NotNull WebhookEmbedBuilder setAuthor(@Nullable WebhookEmbed.EmbedAuthor author)
The author for this embed.
This is displayed above everything else in the embed.- Parameters:
author- The (nullable)WebhookEmbed.EmbedAuthor- Returns:
- The current builder for chaining convenience
-
addField
@NotNull public @NotNull WebhookEmbedBuilder addField(@NotNull WebhookEmbed.EmbedField field)
Adds anWebhookEmbed.EmbedFieldto this embed.
And embed can hold up to 25 total fields. Each row can contain 2-3 fields depending on whether a thumbnail is configured.- Parameters:
field- TheWebhookEmbed.EmbedFieldto add- Returns:
- The current builder for chaining convenience
- Throws:
IllegalStateException- If the maximum amount of fields has already been reached
-
isEmpty
public boolean isEmpty()
Whether this embed is currently empty.- Returns:
- True, if this embed is empty
-
build
@NotNull public @NotNull WebhookEmbed build()
Builds a newWebhookEmbedinstance from the current settings.- Returns:
- The
WebhookEmbed - Throws:
IllegalStateException- If this embed is currently empty
-
fromJDA
@NotNull public static @NotNull WebhookEmbedBuilder fromJDA(@NotNull net.dv8tion.jda.api.entities.MessageEmbed embed)
Converts a JDAMessageEmbedinto a compatible WebhookEmbedBuilder.- Parameters:
embed- The embed- Returns:
- WebhookEmbedBuilder with the converted data
- Throws:
NullPointerException- If null is provided
-
fromJavacord
@NotNull public static @NotNull WebhookEmbedBuilder fromJavacord(@NotNull org.javacord.api.entity.message.embed.Embed embed)
Converts a JavacordEmbedinto a compatible WebhookEmbedBuilder.- Parameters:
embed- The embed- Returns:
- WebhookEmbedBuilder with the converted data
- Throws:
NullPointerException- If null is provided
-
fromD4J
@NotNull @Deprecated public static @NotNull WebhookEmbedBuilder fromD4J(@NotNull @NotNull Consumer<? super discord4j.core.spec.EmbedCreateSpec> callback)
Deprecated.Replace withfromD4J(EmbedCreateSpec)Converts a Discord4JEmbedCreateSpecinto a compatible WebhookEmbedBuilder.- Parameters:
callback- The callback which applies the desired settings to theEmbedCreateSpec- Returns:
- WebhookEmbedBuilder with the converted data
- Throws:
NullPointerException- If null is provided
-
fromD4J
@NotNull public static @NotNull WebhookEmbedBuilder fromD4J(@NotNull @NotNull discord4j.core.spec.EmbedCreateSpec spec)
Converts a Discord4JEmbedCreateSpecinto a compatible WebhookEmbedBuilder.- Parameters:
spec- The embed create spec which applies the desired settings- Returns:
- WebhookEmbedBuilder with the converted data
- Throws:
NullPointerException- If null is provided
-
fromD4J
@NotNull public static @NotNull WebhookEmbedBuilder fromD4J(@NotNull @NotNull discord4j.discordjson.json.EmbedData data)
Converts a Discord4JEmbedDatainto a compatible WebhookEmbedBuilder.- Parameters:
data- The embed data- Returns:
- WebhookEmbedBuilder with the converted data
- Throws:
NullPointerException- If null is provided
-
-