Package org.javacord.api.entity.message
Class WebhookMessageBuilder
- java.lang.Object
-
- org.javacord.api.entity.message.WebhookMessageBuilder
-
public class WebhookMessageBuilder extends java.lang.ObjectThis class can help you to create webhook messages.
-
-
Field Summary
Fields Modifier and Type Field Description protected WebhookMessageBuilderDelegatedelegateThe message delegate used by this instance.
-
Constructor Summary
Constructors Constructor Description WebhookMessageBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description WebhookMessageBuilderaddAttachment(byte[] bytes, java.lang.String fileName)Adds an attachment to the message.WebhookMessageBuilderaddAttachment(byte[] bytes, java.lang.String fileName, java.lang.String description)Adds an attachment to the message.WebhookMessageBuilderaddAttachment(java.awt.image.BufferedImage image, java.lang.String fileName)Adds an attachment to the message.WebhookMessageBuilderaddAttachment(java.awt.image.BufferedImage image, java.lang.String fileName, java.lang.String description)Adds an attachment to the message.WebhookMessageBuilderaddAttachment(java.io.File file)Adds an attachment to the message.WebhookMessageBuilderaddAttachment(java.io.File file, java.lang.String description)Adds an attachment to the message.WebhookMessageBuilderaddAttachment(java.io.InputStream stream, java.lang.String fileName)Adds an attachment to the message.WebhookMessageBuilderaddAttachment(java.io.InputStream stream, java.lang.String fileName, java.lang.String description)Adds an attachment to the message.WebhookMessageBuilderaddAttachment(java.net.URL url)Adds an attachment to the message.WebhookMessageBuilderaddAttachment(java.net.URL url, java.lang.String description)Adds an attachment to the message.WebhookMessageBuilderaddAttachment(Icon icon)Adds an attachment to the message.WebhookMessageBuilderaddAttachment(Icon icon, java.lang.String description)Adds an attachment to the message.WebhookMessageBuilderaddAttachmentAsSpoiler(byte[] bytes, java.lang.String fileName)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddAttachmentAsSpoiler(byte[] bytes, java.lang.String fileName, java.lang.String description)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddAttachmentAsSpoiler(java.awt.image.BufferedImage image, java.lang.String fileName)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddAttachmentAsSpoiler(java.awt.image.BufferedImage image, java.lang.String fileName, java.lang.String description)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddAttachmentAsSpoiler(java.io.File file)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddAttachmentAsSpoiler(java.io.File file, java.lang.String description)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddAttachmentAsSpoiler(java.io.InputStream stream, java.lang.String fileName)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddAttachmentAsSpoiler(java.io.InputStream stream, java.lang.String fileName, java.lang.String description)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddAttachmentAsSpoiler(java.net.URL url)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddAttachmentAsSpoiler(java.net.URL url, java.lang.String description)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddAttachmentAsSpoiler(Icon icon)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddAttachmentAsSpoiler(Icon icon, java.lang.String description)Adds an attachment to the message and marks it as spoiler.WebhookMessageBuilderaddComponents(HighLevelComponent... components)Adds multiple components to the message.WebhookMessageBuilderaddEmbed(EmbedBuilder embed)Adds the embed to the message.WebhookMessageBuilderaddEmbeds(EmbedBuilder... embeds)Adds the embeds to the message.WebhookMessageBuilderappend(java.lang.Object object)Appends the string representation of the object (callingString.valueOf(Object)method) to the message.WebhookMessageBuilderappend(java.lang.String message, MessageDecoration... decorations)Appends a sting with or without decoration to the message.WebhookMessageBuilderappend(Mentionable entity)Appends a mentionable entity (usually a user or channel) to the message.WebhookMessageBuilderappendCode(java.lang.String language, java.lang.String code)Appends code to the message.WebhookMessageBuilderappendNewLine()Appends a new line to the message.static WebhookMessageBuilderfromMessage(Message message)Creates a webhook message builder from a message.java.lang.StringBuildergetStringBuilder()Gets theStringBuilderwhich is used to build the message.WebhookMessageBuilderremoveAllComponents()Removes all components from the message.WebhookMessageBuilderremoveAllEmbeds()Removes all embeds from the message.WebhookMessageBuilderremoveComponent(int index)Remove a component from the message.WebhookMessageBuilderremoveComponent(HighLevelComponent builder)Remove a component from the message.WebhookMessageBuilderremoveEmbed(EmbedBuilder embed)Removes the embed from the message.WebhookMessageBuilderremoveEmbeds(EmbedBuilder... embeds)Removes the embeds from the message.java.util.concurrent.CompletableFuture<Message>send(DiscordApi api, long webhookId, java.lang.String webhookToken)Sends the message.java.util.concurrent.CompletableFuture<Message>send(DiscordApi api, java.lang.String webhookUrl)Sends the message.java.util.concurrent.CompletableFuture<Message>send(DiscordApi api, java.lang.String webhookId, java.lang.String webhookToken)Sends the message.java.util.concurrent.CompletableFuture<Message>send(IncomingWebhook webhook)Sends the message.java.util.concurrent.CompletableFuture<java.lang.Void>sendSilently(DiscordApi api, long webhookId, java.lang.String webhookToken)Sends the message without waiting for a response.java.util.concurrent.CompletableFuture<java.lang.Void>sendSilently(DiscordApi api, java.lang.String webhookUrl)Sends the message without waiting for a response.java.util.concurrent.CompletableFuture<java.lang.Void>sendSilently(DiscordApi api, java.lang.String webhookId, java.lang.String webhookToken)Sends the message without waiting for a response.java.util.concurrent.CompletableFuture<java.lang.Void>sendSilently(IncomingWebhook webhook)Sends the message without waiting for a response.WebhookMessageBuildersetAllowedMentions(AllowedMentions allowedMentions)Controls who will be mentioned if mentions exist in the message.WebhookMessageBuildersetContent(java.lang.String content)Sets the content of the message.WebhookMessageBuildersetDisplayAuthor(MessageAuthor author)Sets the display avatar of the webhook.WebhookMessageBuildersetDisplayAuthor(User author)Sets the display avatar of the webhook.WebhookMessageBuildersetDisplayAvatar(java.net.URL avatarUrl)Sets the display avatar of the webhook.WebhookMessageBuildersetDisplayAvatar(Icon avatar)Sets the display avatar of the webhook.WebhookMessageBuildersetDisplayName(java.lang.String displayName)Sets the display name of the webhook.WebhookMessageBuildersetTts(boolean tts)Sets if the message should be text to speech.
-
-
-
Field Detail
-
delegate
protected final WebhookMessageBuilderDelegate delegate
The message delegate used by this instance.
-
-
Method Detail
-
fromMessage
public static WebhookMessageBuilder fromMessage(Message message)
Creates a webhook message builder from a message.- Parameters:
message- The message to copy.- Returns:
- A webhook message builder which would produce the same text as the given message.
- Throws:
MissingIntentException- See Javadoc ofMessage.getContent()for further explanation.
-
appendCode
public WebhookMessageBuilder appendCode(java.lang.String language, java.lang.String code)
Appends code to the message.- Parameters:
language- The language, e.g. "java".code- The code.- Returns:
- The current instance in order to chain call methods.
-
append
public WebhookMessageBuilder append(java.lang.String message, MessageDecoration... decorations)
Appends a sting with or without decoration to the message.- Parameters:
message- The string to append.decorations- The decorations of the string.- Returns:
- The current instance in order to chain call methods.
-
append
public WebhookMessageBuilder append(Mentionable entity)
Appends a mentionable entity (usually a user or channel) to the message.- Parameters:
entity- The entity to mention.- Returns:
- The current instance in order to chain call methods.
-
append
public WebhookMessageBuilder append(java.lang.Object object)
Appends the string representation of the object (callingString.valueOf(Object)method) to the message.- Parameters:
object- The object to append.- Returns:
- The current instance in order to chain call methods.
- See Also:
StringBuilder.append(Object)
-
appendNewLine
public WebhookMessageBuilder appendNewLine()
Appends a new line to the message.- Returns:
- The current instance in order to chain call methods.
-
addComponents
public WebhookMessageBuilder addComponents(HighLevelComponent... components)
Adds multiple components to the message.- Parameters:
components- The component builders.- Returns:
- The current instance in order to chain call methods.
-
removeAllComponents
public WebhookMessageBuilder removeAllComponents()
Removes all components from the message.- Returns:
- The current instance in order to chain call methods.
-
removeComponent
public WebhookMessageBuilder removeComponent(int index)
Remove a component from the message.- Parameters:
index- The index placement to remove from.- Returns:
- The current instance in order to chain call methods.
-
removeComponent
public WebhookMessageBuilder removeComponent(HighLevelComponent builder)
Remove a component from the message.- Parameters:
builder- The component.- Returns:
- The current instance in order to chain call methods.
-
setContent
public WebhookMessageBuilder setContent(java.lang.String content)
Sets the content of the message. This method overwrites all previous content changes (usingappend(String, MessageDecoration...)for example).- Parameters:
content- The new content of the message.- Returns:
- The current instance in order to chain call methods.
-
addEmbed
public WebhookMessageBuilder addEmbed(EmbedBuilder embed)
Adds the embed to the message.- Parameters:
embed- The embed to add.- Returns:
- The current instance in order to chain call methods.
-
addEmbeds
public WebhookMessageBuilder addEmbeds(EmbedBuilder... embeds)
Adds the embeds to the message.- Parameters:
embeds- The embeds to add.- Returns:
- The current instance in order to chain call methods.
-
removeEmbed
public WebhookMessageBuilder removeEmbed(EmbedBuilder embed)
Removes the embed from the message.- Parameters:
embed- The embed to remove.- Returns:
- The current instance in order to chain call methods.
-
removeEmbeds
public WebhookMessageBuilder removeEmbeds(EmbedBuilder... embeds)
Removes the embeds from the message.- Parameters:
embeds- The embeds to remove.- Returns:
- The current instance in order to chain call methods.
-
removeAllEmbeds
public WebhookMessageBuilder removeAllEmbeds()
Removes all embeds from the message.- Returns:
- The current instance in order to chain call methods.
-
setTts
public WebhookMessageBuilder setTts(boolean tts)
Sets if the message should be text to speech.- Parameters:
tts- Whether the message should be text to speech or not.- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(java.awt.image.BufferedImage image, java.lang.String fileName)
Adds an attachment to the message.- Parameters:
image- The image to add as an attachment.fileName- The file name of the image.- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(java.awt.image.BufferedImage image, java.lang.String fileName, java.lang.String description)
Adds an attachment to the message.- Parameters:
image- The image to add as an attachment.fileName- The file name of the image.description- The description of the image.- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(java.io.File file)
Adds an attachment to the message.- Parameters:
file- The file to add as an attachment.- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(java.io.File file, java.lang.String description)
Adds an attachment to the message.- Parameters:
file- The file to add as an attachment.description- The description of the file.- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(Icon icon)
Adds an attachment to the message.- Parameters:
icon- The icon to add as an attachment.- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(Icon icon, java.lang.String description)
Adds an attachment to the message.- Parameters:
icon- The icon to add as an attachment.description- The description of the icon.- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(java.net.URL url)
Adds an attachment to the message.- Parameters:
url- The url of the attachment.- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(java.net.URL url, java.lang.String description)
Adds an attachment to the message.- Parameters:
url- The url of the attachment.description- The description of the attachment.- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(byte[] bytes, java.lang.String fileName)
Adds an attachment to the message.- Parameters:
bytes- The bytes of the file.fileName- The name of the file.- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(byte[] bytes, java.lang.String fileName, java.lang.String description)
Adds an attachment to the message.- Parameters:
bytes- The bytes of the file.fileName- The name of the file.description- The description of the- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(java.io.InputStream stream, java.lang.String fileName)
Adds an attachment to the message.- Parameters:
stream- The stream of the file.fileName- The name of the file.- Returns:
- The current instance in order to chain call methods.
-
addAttachment
public WebhookMessageBuilder addAttachment(java.io.InputStream stream, java.lang.String fileName, java.lang.String description)
Adds an attachment to the message.- Parameters:
stream- The stream of the file.fileName- The name of the file.description- The description of the file.- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(java.awt.image.BufferedImage image, java.lang.String fileName)
Adds an attachment to the message and marks it as spoiler.- Parameters:
image- The image to add as an attachment.fileName- The file name of the image.- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(java.awt.image.BufferedImage image, java.lang.String fileName, java.lang.String description)
Adds an attachment to the message and marks it as spoiler.- Parameters:
image- The image to add as an attachment.fileName- The file name of the image.description- The description of the image.- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(java.io.File file)
Adds an attachment to the message and marks it as spoiler.- Parameters:
file- The file to add as an attachment.- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(java.io.File file, java.lang.String description)
Adds an attachment to the message and marks it as spoiler.- Parameters:
file- The file to add as an attachment.description- The description of the file.- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(Icon icon)
Adds an attachment to the message and marks it as spoiler.- Parameters:
icon- The icon to add as an attachment.- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(Icon icon, java.lang.String description)
Adds an attachment to the message and marks it as spoiler.- Parameters:
icon- The icon to add as an attachment.description- The description of the icon.- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(java.net.URL url)
Adds an attachment to the message and marks it as spoiler.- Parameters:
url- The url of the attachment.- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(java.net.URL url, java.lang.String description)
Adds an attachment to the message and marks it as spoiler.- Parameters:
url- The url of the attachment.description- The description of the- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(byte[] bytes, java.lang.String fileName)
Adds an attachment to the message and marks it as spoiler.- Parameters:
bytes- The bytes of the file.fileName- The name of the file.- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(byte[] bytes, java.lang.String fileName, java.lang.String description)
Adds an attachment to the message and marks it as spoiler.- Parameters:
bytes- The bytes of the file.fileName- The name of the file.description- The description of the file.- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(java.io.InputStream stream, java.lang.String fileName)
Adds an attachment to the message and marks it as spoiler.- Parameters:
stream- The stream of the file.fileName- The name of the file.- Returns:
- The current instance in order to chain call methods.
-
addAttachmentAsSpoiler
public WebhookMessageBuilder addAttachmentAsSpoiler(java.io.InputStream stream, java.lang.String fileName, java.lang.String description)
Adds an attachment to the message and marks it as spoiler.- Parameters:
stream- The stream of the file.fileName- The name of the file.description- The description of the file.- Returns:
- The current instance in order to chain call methods.
-
setAllowedMentions
public WebhookMessageBuilder setAllowedMentions(AllowedMentions allowedMentions)
Controls who will be mentioned if mentions exist in the message.- Parameters:
allowedMentions- The mention object.- Returns:
- The current instance in order to chain call methods.
-
setDisplayName
public WebhookMessageBuilder setDisplayName(java.lang.String displayName)
Sets the display name of the webhook.- Parameters:
displayName- The display name of the webhook.- Returns:
- The current instance in order to chain call methods.
-
setDisplayAvatar
public WebhookMessageBuilder setDisplayAvatar(java.net.URL avatarUrl)
Sets the display avatar of the webhook.- Parameters:
avatarUrl- The display avatar of the webhook.- Returns:
- The current instance in order to chain call methods.
-
setDisplayAvatar
public WebhookMessageBuilder setDisplayAvatar(Icon avatar)
Sets the display avatar of the webhook.- Parameters:
avatar- The display avatar of the webhook.- Returns:
- The current instance in order to chain call methods.
-
setDisplayAuthor
public WebhookMessageBuilder setDisplayAuthor(MessageAuthor author)
Sets the display avatar of the webhook.- Parameters:
author- The author to take display name and display avatar of.- Returns:
- The current instance in order to chain call methods.
-
setDisplayAuthor
public WebhookMessageBuilder setDisplayAuthor(User author)
Sets the display avatar of the webhook.- Parameters:
author- The author to take display name and display avatar of.- Returns:
- The current instance in order to chain call methods.
-
getStringBuilder
public java.lang.StringBuilder getStringBuilder()
Gets theStringBuilderwhich is used to build the message.- Returns:
- The StringBuilder which is used to build the message.
-
send
public java.util.concurrent.CompletableFuture<Message> send(IncomingWebhook webhook)
Sends the message.- Parameters:
webhook- The webhook from which the message should be sent.- Returns:
- The sent message.
-
send
public java.util.concurrent.CompletableFuture<Message> send(DiscordApi api, long webhookId, java.lang.String webhookToken)
Sends the message.- Parameters:
api- The api instance needed to send and return the message.webhookId- The id of the webhook from which the message should be sent.webhookToken- The token of the webhook from which the message should be sent.- Returns:
- The sent message.
-
send
public java.util.concurrent.CompletableFuture<Message> send(DiscordApi api, java.lang.String webhookId, java.lang.String webhookToken)
Sends the message.- Parameters:
api- The api instance needed to send and return the message.webhookId- The id of the webhook from which the message should be sent.webhookToken- The token of the webhook from which the message should be sent.- Returns:
- The sent message.
-
send
public java.util.concurrent.CompletableFuture<Message> send(DiscordApi api, java.lang.String webhookUrl) throws java.lang.IllegalArgumentException
Sends the message.- Parameters:
api- The api instance needed to send the message.webhookUrl- The url of the webhook from which the message should be sent.- Returns:
- The sent message.
- Throws:
java.lang.IllegalArgumentException- If the link isn't valid.
-
sendSilently
public java.util.concurrent.CompletableFuture<java.lang.Void> sendSilently(IncomingWebhook webhook)
Sends the message without waiting for a response.- Parameters:
webhook- The webhook from which the message should be sent.- Returns:
- A CompletableFuture indicating whether sending the request to discord was successful.
-
sendSilently
public java.util.concurrent.CompletableFuture<java.lang.Void> sendSilently(DiscordApi api, long webhookId, java.lang.String webhookToken)
Sends the message without waiting for a response.- Parameters:
api- The api instance needed to send the message.webhookId- The id of the webhook from which the message should be sent.webhookToken- The token of the webhook from which the message should be sent.- Returns:
- A CompletableFuture indicating whether sending the request to discord was successful.
-
sendSilently
public java.util.concurrent.CompletableFuture<java.lang.Void> sendSilently(DiscordApi api, java.lang.String webhookId, java.lang.String webhookToken)
Sends the message without waiting for a response.- Parameters:
api- The api instance needed to send the message.webhookId- The id of the webhook from which the message should be sent.webhookToken- The token of the webhook from which the message should be sent.- Returns:
- A CompletableFuture indicating whether sending the request to discord was successful.
-
sendSilently
public java.util.concurrent.CompletableFuture<java.lang.Void> sendSilently(DiscordApi api, java.lang.String webhookUrl) throws java.lang.IllegalArgumentException
Sends the message without waiting for a response.- Parameters:
api- The api instance needed to send the message.webhookUrl- The url of the webhook from which the message should be sent.- Returns:
- A CompletableFuture indicating whether sending the request to discord was successful.
- Throws:
java.lang.IllegalArgumentException- If the link isn't valid.
-
-