public class WebhookMessageBuilder
extends java.lang.Object
WebhookMessage
Modifier and Type | Field | Description |
---|---|---|
static int |
MAX_FILES |
The maximum amount of files that can be added to a message (10)
|
Constructor | Description |
---|---|
WebhookMessageBuilder() |
Creates a new empty WebhookMessageBuilder
|
WebhookMessageBuilder(Message message) |
Creates a new WebhookMessageBuilder and applies
the information of the provided
Message
as preset values. |
Modifier and Type | Method | Description |
---|---|---|
WebhookMessageBuilder |
addEmbeds(java.util.Collection<MessageEmbed> embeds) |
Adds the provided
MessageEmbeds
to this builder. |
WebhookMessageBuilder |
addEmbeds(MessageEmbed... embeds) |
Adds the provided
MessageEmbeds
to this builder. |
WebhookMessageBuilder |
addFile(java.io.File file) |
Adds the provided file to the resulting message.
|
WebhookMessageBuilder |
addFile(java.lang.String name,
byte[] data) |
Adds the provided file to the resulting message.
|
WebhookMessageBuilder |
addFile(java.lang.String name,
java.io.File file) |
Adds the provided file to the resulting message.
|
WebhookMessageBuilder |
addFile(java.lang.String name,
java.io.InputStream data) |
Adds the provided file to the resulting message.
|
WebhookMessageBuilder |
append(java.lang.String content) |
Appends to the currently set content of the resulting message.
|
WebhookMessage |
build() |
Builds a
WebhookMessage instance
with the current state of this builder. |
int |
getFileAmount() |
The amount of files added to this WebhookMessageBuilder instance
|
boolean |
isEmpty() |
Whether this WebhookMessageBuilder contains any readable content.
|
WebhookMessageBuilder |
reset() |
Resets this builder to default settings.
|
WebhookMessageBuilder |
resetEmbeds() |
Removes all embeds from this builder.
|
WebhookMessageBuilder |
resetFiles() |
Removes all added resources.
|
WebhookMessageBuilder |
setAvatarUrl(java.lang.String avatarUrl) |
Sets the avatar url that should be used for the resulting message.
|
WebhookMessageBuilder |
setContent(java.lang.String content) |
Sets the content of the resulting message.
|
WebhookMessageBuilder |
setTTS(boolean tts) |
Sets whether the resulting message should use Text-To-Speech.
|
WebhookMessageBuilder |
setUsername(java.lang.String username) |
Sets the username that should be used for the resulting message.
|
public static final int MAX_FILES
public WebhookMessageBuilder(Message message)
Message
as preset values.
message
- The Message
used
to set initial values of the builderpublic WebhookMessageBuilder()
public boolean isEmpty()
WebhookMessage
.public int getFileAmount()
public WebhookMessageBuilder reset()
public WebhookMessageBuilder resetFiles()
getFileAmount()
will report 0
after this happened, however the allocated array will remain.public WebhookMessageBuilder resetEmbeds()
public WebhookMessageBuilder addEmbeds(MessageEmbed... embeds)
MessageEmbeds
to this builder.
You can send up to 10 embeds per message! If more are sent they will not be displayed.
embeds
- The embeds to addjava.lang.IllegalArgumentException
- If any of the provided embeds is null
or exceeds the maximum total character count of MessageEmbed.EMBED_MAX_LENGTH_BOT
public WebhookMessageBuilder addEmbeds(java.util.Collection<MessageEmbed> embeds)
MessageEmbeds
to this builder.
You can send up to 10 embeds per message! If more are sent they will not be displayed.
embeds
- The embeds to addjava.lang.IllegalArgumentException
- If any of the provided embeds is null
or exceeds the maximum total character count of MessageEmbed.EMBED_MAX_LENGTH_BOT
public WebhookMessageBuilder setContent(java.lang.String content)
content
- The new contentjava.lang.IllegalArgumentException
- If the provided content exceeds 2000
characters in lengthpublic WebhookMessageBuilder append(java.lang.String content)
content
- The content to appendjava.lang.IllegalArgumentException
- If the provided content is null
or
the resulting content would exceed 2000
characters in lengthpublic WebhookMessageBuilder setUsername(java.lang.String username)
username
- The username to use for this messagepublic WebhookMessageBuilder setAvatarUrl(java.lang.String avatarUrl)
avatarUrl
- The avatar url to use for this messagepublic WebhookMessageBuilder addFile(java.io.File file)
addFile(String, File)
.file
- The file to addjava.lang.IllegalArgumentException
- If the provided file is null, does not exist, or is not readablejava.lang.IllegalStateException
- If the file limit has already been reachedresetFiles()
public WebhookMessageBuilder addFile(java.lang.String name, java.io.File file)
name
- The name to use for this filefile
- The file to addjava.lang.IllegalArgumentException
- If the provided file is null, does not exist, or is not readablejava.lang.IllegalStateException
- If the file limit has already been reachedresetFiles()
public WebhookMessageBuilder addFile(java.lang.String name, byte[] data)
name
- The name to use for this filedata
- The file data to addjava.lang.IllegalArgumentException
- If the provided name data is nulljava.lang.IllegalStateException
- If the file limit has already been reachedresetFiles()
public WebhookMessageBuilder addFile(java.lang.String name, java.io.InputStream data)
name
- The name to use for this filedata
- The file data to addjava.lang.IllegalArgumentException
- If the provided name or data is nulljava.lang.IllegalStateException
- If the file limit has already been reachedresetFiles()
public WebhookMessageBuilder setTTS(boolean tts)
tts
- True, if the resulting message should use Text-To-Speechpublic WebhookMessage build()
WebhookMessage
instance
with the current state of this builder.WebhookMessage
java.lang.IllegalStateException
- If this builder is empty