public class WebhookMessageBuilder
extends java.lang.Object
WebhookMessage
Constructor and 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 and 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 |
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. |
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 |
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 |
setFile(byte[] data,
java.lang.String fileName)
Sets the attached file for the resulting message.
|
WebhookMessageBuilder |
setFile(java.io.File file)
Sets the attached file for the resulting message.
|
WebhookMessageBuilder |
setFile(java.io.File file,
java.lang.String fileName)
Sets the attached file for the resulting message.
|
WebhookMessageBuilder |
setFile(java.io.InputStream data,
java.lang.String fileName)
Sets the attached file for 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 WebhookMessageBuilder(Message message)
Message
as preset values.
message
- The Message
used
to set initial values of the builderpublic WebhookMessageBuilder()
public boolean isEmpty()
WebhookMessage
.public WebhookMessageBuilder reset()
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 setFile(java.io.File file)
file
- The File
that should be attached to the messagejava.lang.IllegalArgumentException
- If the provided file is null
, does not exist, is not readable
or exceeds the maximum size of 8MBpublic WebhookMessageBuilder setFile(java.io.File file, java.lang.String fileName)
file
- The File
that should be attached to the messagefileName
- The name that should be used for this attachmentjava.lang.IllegalArgumentException
- If the provided file is does not exist, is not readable
or exceeds the maximum size of 8MBpublic WebhookMessageBuilder setFile(byte[] data, java.lang.String fileName)
data
- The byte[]
data that should be attached to the messagefileName
- The name that should be used for this attachmentjava.lang.IllegalArgumentException
- If the provided data exceeds the maximum size of 8MBpublic WebhookMessageBuilder setFile(java.io.InputStream data, java.lang.String fileName)
data
- The InputStream
data that should be attached to the messagefileName
- The name that should be used for this attachmentpublic 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