public class WebhookMessageBuilder
extends java.lang.Object
WebhookMessage| Modifier and Type | Field and Description |
|---|---|
protected AllowedMentions |
allowedMentions |
protected java.lang.String |
avatarUrl |
protected java.lang.StringBuilder |
content |
protected java.util.List<WebhookEmbed> |
embeds |
protected MessageAttachment[] |
files |
protected int |
flags |
protected boolean |
isTTS |
protected java.lang.String |
username |
| Constructor and Description |
|---|
WebhookMessageBuilder() |
| Modifier and Type | Method and Description |
|---|---|
@NotNull WebhookMessageBuilder |
addEmbeds(@NotNull java.util.Collection<? extends WebhookEmbed> embeds)
Adds the provided embeds to the builder
|
@NotNull WebhookMessageBuilder |
addEmbeds(WebhookEmbed... embeds)
Adds the provided embeds to the builder
|
@NotNull WebhookMessageBuilder |
addFile(@NotNull java.io.File file)
Adds the provided file as an attachment to this message.
|
@NotNull WebhookMessageBuilder |
addFile(@NotNull java.lang.String name,
@NotNull byte[] data)
Adds the provided data as a file attachment to this message.
|
@NotNull WebhookMessageBuilder |
addFile(@NotNull java.lang.String name,
@NotNull java.io.File file)
Adds the provided file as an attachment to this message.
|
@NotNull WebhookMessageBuilder |
addFile(@NotNull java.lang.String name,
@NotNull java.io.InputStream data)
Adds the provided data as a file attachment to this message.
|
@NotNull WebhookMessageBuilder |
append(@NotNull java.lang.String content)
Appends the provided content to the already
present content in this message.
|
@NotNull WebhookMessage |
build()
Constructs the
WebhookMessage
from the current configurations. |
static @NotNull WebhookMessageBuilder |
fromD4J(@NotNull java.util.function.Consumer<? super discord4j.core.spec.MessageCreateSpec> callback)
Deprecated.
Replace with
fromD4J(MessageCreateSpec) |
static @NotNull WebhookMessageBuilder |
fromD4J(@NotNull discord4j.core.spec.MessageCreateSpec spec)
Converts a Discord4J
MessageCreateSpec into a compatible WebhookMessageBuilder. |
static @NotNull WebhookMessageBuilder |
fromD4J(@NotNull discord4j.core.spec.MessageEditSpec spec)
Converts a Discord4J
MessageCreateSpec into a compatible WebhookMessageBuilder. |
static @NotNull WebhookMessageBuilder |
fromJavacord(org.javacord.api.entity.message.Message message)
Converts a Javacord
Message into a compatible WebhookMessageBuilder. |
static @NotNull WebhookMessageBuilder |
fromJDA(net.dv8tion.jda.api.entities.Message message)
Converts a JDA
Message into a compatible WebhookMessageBuilder. |
int |
getFileAmount()
The amount of files currently added
|
boolean |
isEmpty()
Whether this builder is currently empty
|
@NotNull WebhookMessageBuilder |
reset()
Clears this builder to its default state
|
@NotNull WebhookMessageBuilder |
resetEmbeds()
Clears all embeds currently added this builder
|
@NotNull WebhookMessageBuilder |
resetFiles()
Clears all files currently added to this builder
|
@NotNull WebhookMessageBuilder |
setAllowedMentions(@NotNull AllowedMentions mentions)
The mention whitelist.
|
@NotNull WebhookMessageBuilder |
setAvatarUrl(@Nullable java.lang.String avatarUrl)
The avatar url to use for this message.
|
@NotNull WebhookMessageBuilder |
setContent(@Nullable java.lang.String content)
Configures the content for this builder
|
@NotNull WebhookMessageBuilder |
setEphemeral(boolean ephemeral)
Whether the message should be ephemeral (only works for interaction webhooks).
|
@NotNull WebhookMessageBuilder |
setTTS(boolean tts)
Whether this message should use Text-to-Speech (TTS)
|
@NotNull WebhookMessageBuilder |
setUsername(@Nullable java.lang.String username)
The username to use for this message.
|
protected final java.lang.StringBuilder content
protected final java.util.List<WebhookEmbed> embeds
protected final MessageAttachment[] files
protected AllowedMentions allowedMentions
protected java.lang.String username
protected java.lang.String avatarUrl
protected boolean isTTS
protected int flags
public boolean isEmpty()
public int getFileAmount()
@NotNull public @NotNull WebhookMessageBuilder reset()
@NotNull public @NotNull WebhookMessageBuilder resetFiles()
@NotNull public @NotNull WebhookMessageBuilder resetEmbeds()
@NotNull public @NotNull WebhookMessageBuilder setAllowedMentions(@NotNull @NotNull AllowedMentions mentions)
AllowedMentions for more details.mentions - The mention whitelistjava.lang.NullPointerException - If provided null@NotNull public @NotNull WebhookMessageBuilder addEmbeds(@NotNull WebhookEmbed... embeds)
embeds - The embeds to addjava.lang.NullPointerException - If provided with nulljava.lang.IllegalStateException - If more than are added@NotNull public @NotNull WebhookMessageBuilder addEmbeds(@NotNull @NotNull java.util.Collection<? extends WebhookEmbed> embeds)
embeds - The embeds to addjava.lang.NullPointerException - If provided with nulljava.lang.IllegalStateException - If more than are added@NotNull public @NotNull WebhookMessageBuilder setContent(@Nullable @Nullable java.lang.String content)
content - The (nullable) content to usejava.lang.IllegalArgumentException - If the content is larger than 2000 characters@NotNull public @NotNull WebhookMessageBuilder append(@NotNull @NotNull java.lang.String content)
content - The content to appendjava.lang.NullPointerException - If provided with nulljava.lang.IllegalArgumentException - If the content exceeds 2000 characters@NotNull public @NotNull WebhookMessageBuilder setUsername(@Nullable @Nullable java.lang.String username)
username - The (nullable) username to use@NotNull public @NotNull WebhookMessageBuilder setAvatarUrl(@Nullable @Nullable java.lang.String avatarUrl)
avatarUrl - The (nullable) avatar url to use@NotNull public @NotNull WebhookMessageBuilder setTTS(boolean tts)
tts - True, if this message should use tts@NotNull public @NotNull WebhookMessageBuilder setEphemeral(boolean ephemeral)
ephemeral - True if the message should be ephemeral, false otherwise@NotNull public @NotNull WebhookMessageBuilder addFile(@NotNull @NotNull java.io.File file)
file - The file to attachjava.lang.NullPointerException - If provided with null@NotNull public @NotNull WebhookMessageBuilder addFile(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.io.File file)
name - The alternative name that should be used insteadfile - The file to attachjava.lang.NullPointerException - If provided with null@NotNull public @NotNull WebhookMessageBuilder addFile(@NotNull @NotNull java.lang.String name, @NotNull @NotNull byte[] data)
name - The alternative name that should be useddata - The data to attach as a filejava.lang.NullPointerException - If provided with null@NotNull public @NotNull WebhookMessageBuilder addFile(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.io.InputStream data)
name - The alternative name that should be useddata - The data to attach as a filejava.lang.NullPointerException - If provided with null@NotNull public @NotNull WebhookMessage build()
WebhookMessage
from the current configurations.WebhookMessage@NotNull public static @NotNull WebhookMessageBuilder fromJDA(@NotNull net.dv8tion.jda.api.entities.Message message)
Message into a compatible WebhookMessageBuilder.message - The messagejava.lang.NullPointerException - If null is provided@NotNull public static @NotNull WebhookMessageBuilder fromJavacord(@NotNull org.javacord.api.entity.message.Message message)
Message into a compatible WebhookMessageBuilder.message - The messagejava.lang.NullPointerException - If null is provided@NotNull @Deprecated public static @NotNull WebhookMessageBuilder fromD4J(@NotNull @NotNull java.util.function.Consumer<? super discord4j.core.spec.MessageCreateSpec> callback)
fromD4J(MessageCreateSpec)MessageCreateSpec into a compatible WebhookMessageBuilder.callback - The callback used to specify the desired message settingsjava.lang.NullPointerException - If null is provided@NotNull public static @NotNull WebhookMessageBuilder fromD4J(@NotNull @NotNull discord4j.core.spec.MessageCreateSpec spec)
MessageCreateSpec into a compatible WebhookMessageBuilder.spec - The message create spec used to specify the desired message settingsjava.lang.NullPointerException - If null is provided@NotNull public static @NotNull WebhookMessageBuilder fromD4J(@NotNull @NotNull discord4j.core.spec.MessageEditSpec spec)
MessageCreateSpec into a compatible WebhookMessageBuilder.spec - The message create spec used to specify the desired message settingsjava.lang.NullPointerException - If null is provided