Package com.mewna.catnip.entity.builder
Class EmbedBuilder
java.lang.Object
com.mewna.catnip.entity.builder.EmbedBuilder
Build a new embed to be used via the REST API.
- Since:
- 9/4/18.
- Author:
- amy
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionauthor
(Embed.Author author) Set the embed's author.Set the embed's author.Set the embed's author.Set the embed's author.build()
Build the embed.Set the color of the embed.Set the color of the embed.description
(String description) field
(Embed.Field field) Add a new field to the embed.Add a new field to the embed.footer
(Embed.Footer footer) Add a footer to the embed.Set the embed's image.replaceAtIndex
(int index, Embed.Field field) Replaces the field associated with a specific index with a new field more efficiently.replaceAtIndex
(int index, String name, String value, boolean inline) Replaces the field associated with a specific index with a new field more efficiently.Set the embed's thumbnail.timestamp
(TemporalAccessor temporal) Sets the timestamp of the embed.
-
Constructor Details
-
EmbedBuilder
-
EmbedBuilder
public EmbedBuilder()
-
-
Method Details
-
timestamp
Sets the timestamp of the embed. ATemporalAccessor
that isn't anOffsetDateTime
will be converted to one if possible.- Parameters:
temporal
- ATemporalAccessor
to set.- Returns:
- Itself.
- Throws:
DateTimeException
- If theTemporalAccessor
cannot be converted to anOffsetDateTime
.
-
color
Set the color of the embed. The alpha bits will be ignored.- Parameters:
color
- The color to set.- Returns:
- Itself.
-
color
Set the color of the embed. The alpha bits will be ignored.- Parameters:
color
- The color to set.- Returns:
- Itself.
-
image
Set the embed's image.- Parameters:
url
- The URL of the image.- Returns:
- Itself.
-
thumbnail
Set the embed's thumbnail.- Parameters:
url
- The URL of the thumbnail image.- Returns:
- Itself.
-
author
Set the embed's author.- Parameters:
name
- The author's name.- Returns:
- Itself.
-
author
Set the embed's author.- Parameters:
name
- The author's name.url
- The URL of the author's page.- Returns:
- Itself.
-
author
@Nonnull @CheckReturnValue public EmbedBuilder author(@Nullable String name, @Nullable String url, @Nullable String iconUrl) Set the embed's author.- Parameters:
name
- The author's name.url
- The URL of the author's page.iconUrl
- The URL for the author's icon.- Returns:
- Itself.
-
author
Set the embed's author.- Parameters:
author
- The new author.- Returns:
- Itself.
-
field
@Nonnull @CheckReturnValue public EmbedBuilder field(@Nonnull String name, @Nonnull String value, boolean inline) Add a new field to the embed.- Parameters:
name
- The field's name.value
- The field's value.inline
- Whether or not the field should be inline.- Returns:
- Itself.
-
field
Add a new field to the embed.- Parameters:
field
- The field to add.- Returns:
- Itself.
- Throws:
IllegalStateException
- If more than 25 fields are added.
-
replaceAtIndex
@Nonnull @CheckReturnValue public EmbedBuilder replaceAtIndex(@Nonnegative int index, @Nonnull String name, @Nonnull String value, boolean inline) Replaces the field associated with a specific index with a new field more efficiently.- Parameters:
index
- The non-negative and under-25 index of the field to replace.name
- The non-null name of the new field.value
- The non-null value of the new field.inline
- Whether or not the field should be inline.- Returns:
- Itself.
-
replaceAtIndex
@Nonnull @CheckReturnValue public EmbedBuilder replaceAtIndex(@Nonnegative int index, @Nonnull Embed.Field field) Replaces the field associated with a specific index with a new field more efficiently.- Parameters:
index
- The non-negative and under-25 index of the field to replace.field
- The non-nullfield
instance.- Returns:
- Itself.
- Throws:
IndexOutOfBoundsException
- If the field index is smaller than 0, larger than 24 or larger or equal to the amount of fields added.
-
build
Build the embed.- Returns:
- The new embed.
-
title
- Returns:
this
.
-
description
- Returns:
this
.
-
url
- Returns:
this
.
-