Interface WebhookClient<T>
- All Known Subinterfaces:
InteractionHook
Interactions can use these through
IDeferrableCallback.getHook()
.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault RestAction<Void>
deleteMessageById
(long messageId) Delete a message from this webhook.deleteMessageById
(String messageId) Delete a message from this webhook.default WebhookMessageUpdateAction<T>
editMessageById
(long messageId, byte[] data, String name, AttachmentOption... options) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageById
(long messageId, File file, String name, AttachmentOption... options) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageById
(long messageId, File file, AttachmentOption... options) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageById
(long messageId, InputStream data, String name, AttachmentOption... options) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageById
(long messageId, String content) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageById
(long messageId, Message message) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageById
(String messageId, byte[] data, String name, AttachmentOption... options) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageById
(String messageId, File file, String name, AttachmentOption... options) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageById
(String messageId, File file, AttachmentOption... options) Edit an existing message sent by this webhook.editMessageById
(String messageId, InputStream data, String name, AttachmentOption... options) Edit an existing message sent by this webhook.editMessageById
(String messageId, String content) Edit an existing message sent by this webhook.editMessageById
(String messageId, Message message) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageComponentsById
(long messageId, Collection<? extends LayoutComponent> components) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageComponentsById
(long messageId, LayoutComponent... components) Edit an existing message sent by this webhook.editMessageComponentsById
(String messageId, Collection<? extends LayoutComponent> components) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageComponentsById
(String messageId, LayoutComponent... components) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageEmbedsById
(long messageId, Collection<? extends MessageEmbed> embeds) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageEmbedsById
(long messageId, MessageEmbed... embeds) Edit an existing message sent by this webhook.editMessageEmbedsById
(String messageId, Collection<? extends MessageEmbed> embeds) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageEmbedsById
(String messageId, MessageEmbed... embeds) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageFormatById
(long messageId, String format, Object... args) Edit an existing message sent by this webhook.default WebhookMessageUpdateAction<T>
editMessageFormatById
(String messageId, String format, Object... args) Edit an existing message sent by this webhook.default WebhookMessageAction<T>
sendFile
(byte[] data, String name, AttachmentOption... options) Send a message to this webhook.default WebhookMessageAction<T>
sendFile
(File file, String name, AttachmentOption... options) Send a message to this webhook.default WebhookMessageAction<T>
sendFile
(File file, AttachmentOption... options) Send a message to this webhook.sendFile
(InputStream data, String name, AttachmentOption... options) Send a message to this webhook.sendMessage
(String content) Send a message to this webhook.sendMessage
(Message message) Send a message to this webhook.sendMessageEmbeds
(Collection<? extends MessageEmbed> embeds) Send a message to this webhook.default WebhookMessageAction<T>
sendMessageEmbeds
(MessageEmbed embed, MessageEmbed... embeds) Send a message to this webhook.default WebhookMessageAction<T>
sendMessageFormat
(String format, Object... args) Send a message to this webhook.
-
Method Details
-
sendMessage
Send a message to this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.
- Parameters:
content
- The message content- Returns:
WebhookMessageAction
- Throws:
IllegalArgumentException
- If the content is null, empty, or longer thanMessage.MAX_CONTENT_LENGTH
-
sendMessage
Send a message to this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.
- Parameters:
message
- The message to send- Returns:
WebhookMessageAction
- Throws:
IllegalArgumentException
- If the message is null
-
sendMessageFormat
@Nonnull @CheckReturnValue default WebhookMessageAction<T> sendMessageFormat(@Nonnull String format, @Nonnull Object... args) Send a message to this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.
- Parameters:
format
- Format string for the message contentargs
- Format arguments for the content- Returns:
WebhookMessageAction
- Throws:
IllegalArgumentException
- If the format string is null or the resulting content is longer thanMessage.MAX_CONTENT_LENGTH
-
sendMessageEmbeds
@Nonnull @CheckReturnValue WebhookMessageAction<T> sendMessageEmbeds(@Nonnull Collection<? extends MessageEmbed> embeds) Send a message to this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.
- Parameters:
embeds
-MessageEmbeds
to use (up to 10 in total)- Returns:
WebhookMessageAction
- Throws:
IllegalArgumentException
- If any of the embeds are null, more than 10, or longer thanMessageEmbed.EMBED_MAX_LENGTH_BOT
.
-
sendMessageEmbeds
@Nonnull @CheckReturnValue default WebhookMessageAction<T> sendMessageEmbeds(@Nonnull MessageEmbed embed, @Nonnull MessageEmbed... embeds) Send a message to this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.
- Parameters:
embed
-MessageEmbed
to useembeds
- AdditionalMessageEmbeds
to use (up to 10 in total)- Returns:
WebhookMessageAction
- Throws:
IllegalArgumentException
- If any of the embeds are null, more than 10, or longer thanMessageEmbed.EMBED_MAX_LENGTH_BOT
.
-
sendFile
@Nonnull @CheckReturnValue WebhookMessageAction<T> sendFile(@Nonnull InputStream data, @Nonnull String name, @Nonnull AttachmentOption... options) Send a message to this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); InputStream file = new FileInputStream("image.png"); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.sendFile(file, "cat.png").addEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.REQUEST_ENTITY_TOO_LARGE
The file exceeds the maximum upload size ofMessage.MAX_FILE_SIZE
- Parameters:
data
- The InputStream data to upload to the webhook.name
- The file name that should be sent to discord
Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...)
for information about this parameter.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageAction
- Throws:
IllegalArgumentException
- If the provided file or filename isnull
orempty
.
-
sendFile
@Nonnull @CheckReturnValue default WebhookMessageAction<T> sendFile(@Nonnull File file, @Nonnull AttachmentOption... options) Send a message to this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.This is a shortcut to
sendFile(java.io.File, String, AttachmentOption...)
by way of usingFile.getName()
.sendFile(file, file.getName())
Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); File data = new File("image.png"); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.sendFile(file, "cat.png").addEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.REQUEST_ENTITY_TOO_LARGE
The file exceeds the maximum upload size ofMessage.MAX_FILE_SIZE
- Parameters:
file
- TheFile
data to upload to the webhook.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageAction
- Throws:
IllegalArgumentException
- If the provided file isnull
.
-
sendFile
@Nonnull @CheckReturnValue default WebhookMessageAction<T> sendFile(@Nonnull File file, @Nonnull String name, @Nonnull AttachmentOption... options) Send a message to this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.The
name
parameter is used to inform Discord about what the file should be called. This is 2 fold:- The file name provided is the name that is found in
Message.Attachment.getFileName()
after upload and it is the name that will show up in the client when the upload is displayed.
Note: The fileName does not show up on the Desktop client for images. It does on mobile however. - The extension of the provided fileName also determines how Discord will treat the file. Discord currently only has special handling for image file types, but the fileName's extension must indicate that it is an image file. This means it has to end in something like .png, .jpg, .jpeg, .gif, etc. As a note, you can also not provide a full name for the file and instead ONLY provide the extension like "png" or "gif" and Discord will generate a name for the upload and append the fileName as the extension.
Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); byte[] data = IOUtils.readAllBytes(new FileInputStream("image.png")); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.sendFile(file, "cat.png").addEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.REQUEST_ENTITY_TOO_LARGE
The file exceeds the maximum upload size ofMessage.MAX_FILE_SIZE
- Parameters:
file
- TheFile
data to upload to the webhook.name
- The file name that should be sent to discordoptions
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageAction
- Throws:
IllegalArgumentException
- If the provided file or filename isnull
orempty
.
- The file name provided is the name that is found in
-
sendFile
@Nonnull @CheckReturnValue default WebhookMessageAction<T> sendFile(@Nonnull byte[] data, @Nonnull String name, @Nonnull AttachmentOption... options) Send a message to this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); byte[] data = IOUtils.readAllBytes(new FileInputStream("image.png")); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.sendFile(file, "cat.png").addEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.REQUEST_ENTITY_TOO_LARGE
The file exceeds the maximum upload size ofMessage.MAX_FILE_SIZE
- Parameters:
data
- Thebyte[]
data to upload to the webhook.name
- The file name that should be sent to discord
Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...)
for information about this parameter.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageAction
- Throws:
IllegalArgumentException
- If the provided file or filename isnull
orempty
.
-
editMessageById
@Nonnull @CheckReturnValue WebhookMessageUpdateAction<T> editMessageById(@Nonnull String messageId, @Nonnull String content) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.content
- The new message content to use- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided content is null, empty, or longer thanMessage.MAX_CONTENT_LENGTH
-
editMessageById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageById(long messageId, @Nonnull String content) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.content
- The new message content to use- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided content is null, empty, or longer thanMessage.MAX_CONTENT_LENGTH
-
editMessageById
@Nonnull @CheckReturnValue WebhookMessageUpdateAction<T> editMessageById(@Nonnull String messageId, @Nonnull Message message) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.message
- The new message to replace the existing message with- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided message is null
-
editMessageById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageById(long messageId, Message message) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.message
- The new message to replace the existing message with- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided message is null
-
editMessageFormatById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageFormatById(@Nonnull String messageId, @Nonnull String format, @Nonnull Object... args) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.format
- Format string for the message contentargs
- Format arguments for the content- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the formatted string is null, empty, or longer thanMessage.MAX_CONTENT_LENGTH
-
editMessageFormatById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageFormatById(long messageId, @Nonnull String format, @Nonnull Object... args) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.format
- Format string for the message contentargs
- Format arguments for the content- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the formatted string is null, empty, or longer thanMessage.MAX_CONTENT_LENGTH
-
editMessageEmbedsById
@Nonnull @CheckReturnValue WebhookMessageUpdateAction<T> editMessageEmbedsById(@Nonnull String messageId, @Nonnull Collection<? extends MessageEmbed> embeds) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.embeds
-MessageEmbeds
to use (up to 10 in total)- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided embeds are null, or more than 10
-
editMessageEmbedsById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageEmbedsById(long messageId, @Nonnull Collection<? extends MessageEmbed> embeds) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.embeds
-MessageEmbeds
to use (up to 10 in total)- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided embeds are null, or more than 10
-
editMessageEmbedsById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageEmbedsById(@Nonnull String messageId, @Nonnull MessageEmbed... embeds) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.embeds
- The newMessageEmbeds
to use- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided embeds are null, or more than 10
-
editMessageEmbedsById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageEmbedsById(long messageId, @Nonnull MessageEmbed... embeds) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.embeds
- The newMessageEmbeds
to use- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided embeds are null, or more than 10
-
editMessageComponentsById
@Nonnull @CheckReturnValue WebhookMessageUpdateAction<T> editMessageComponentsById(@Nonnull String messageId, @Nonnull Collection<? extends LayoutComponent> components) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.components
- The new component layouts for this message, such asActionRows
- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided components are null, or more than 5 layouts are provided
-
editMessageComponentsById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageComponentsById(long messageId, @Nonnull Collection<? extends LayoutComponent> components) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.components
- The new component layouts for this message, such asActionRows
- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided components are null, or more than 5 layouts are provided
-
editMessageComponentsById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageComponentsById(@Nonnull String messageId, @Nonnull LayoutComponent... components) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.components
- The new component layouts for this message, such asActionRows
- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided components are null, or more than 5 layouts are provided
-
editMessageComponentsById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageComponentsById(long messageId, @Nonnull LayoutComponent... components) Edit an existing message sent by this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.components
- The new component layouts for this message, such asActionRows
- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided components are null, or more than 5 layouts are provided
-
editMessageById
@Nonnull @CheckReturnValue WebhookMessageUpdateAction<T> editMessageById(@Nonnull String messageId, @Nonnull InputStream data, @Nonnull String name, @Nonnull AttachmentOption... options) Edit an existing message sent by this webhook.
The provided file will be appended to the message. You cannot delete or edit existing files on a message.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); InputStream file = new FileInputStream("image.png"); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.editMessageById(messageId, file, "cat.png").setEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.data
- The InputStream data to upload to the webhook.name
- The file name that should be sent to discord
Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...)
for information about this parameter.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided message id, data, or filename isnull
.
-
editMessageById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageById(@Nonnull String messageId, @Nonnull File file, @Nonnull AttachmentOption... options) Edit an existing message sent by this webhook.
The provided file will be appended to the message. You cannot delete or edit existing files on a message.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.This is a shortcut to
editMessageById(java.lang.String, java.io.File, String, AttachmentOption...)
by way of usingFile.getName()
.editMessageById(messageId, file, file.getName())
Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); File file = new File("image.png"); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.editMessageById(messageId, file, "cat.png").setEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.file
- TheFile
data to upload to the webhook.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided message id or file isnull
.
-
editMessageById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageById(@Nonnull String messageId, @Nonnull File file, @Nonnull String name, @Nonnull AttachmentOption... options) Edit an existing message sent by this webhook.
The provided file will be appended to the message. You cannot delete or edit existing files on a message.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); File file = new File("image.png"); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.editMessageById(messageId, file, "cat.png").setEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.file
- TheFile
data to upload to the webhook.name
- The file name that should be sent to discord
Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...)
for information about this parameter.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided file, message id, or filename isnull
.
-
editMessageById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageById(@Nonnull String messageId, @Nonnull byte[] data, @Nonnull String name, @Nonnull AttachmentOption... options) Edit an existing message sent by this webhook.
The provided file will be appended to the message. You cannot delete or edit existing files on a message.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); InputStream file = new FileInputStream("image.png"); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.editMessageById(messageId, file, "cat.png").setEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.data
- The InputStream data to upload to the webhook.name
- The file name that should be sent to discord
Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...)
for information about this parameter.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided message id, data, or filename isnull
.
-
editMessageById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageById(long messageId, @Nonnull InputStream data, @Nonnull String name, @Nonnull AttachmentOption... options) Edit an existing message sent by this webhook.
The provided file will be appended to the message. You cannot delete or edit existing files on a message.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); InputStream file = new FileInputStream("image.png"); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.editMessageById(messageId, file, "cat.png").setEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.data
- The InputStream data to upload to the webhook.name
- The file name that should be sent to discord
Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...)
for information about this parameter.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided data or filename isnull
.
-
editMessageById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageById(long messageId, @Nonnull File file, @Nonnull AttachmentOption... options) Edit an existing message sent by this webhook.
The provided file will be appended to the message. You cannot delete or edit existing files on a message.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.This is a shortcut to
sendFile(java.io.File, String, AttachmentOption...)
by way of usingFile.getName()
.sendFile(file, file.getName())
Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); File file = new File("image.png"); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.editMessageById(messageId, file, "cat.png").setEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.file
- TheFile
data to upload to the webhook.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided file isnull
.
-
editMessageById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageById(long messageId, @Nonnull File file, @Nonnull String name, @Nonnull AttachmentOption... options) Edit an existing message sent by this webhook.
The provided file will be appended to the message. You cannot delete or edit existing files on a message.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); File file = new File("image.png"); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.editMessageById(messageId, file, "cat.png").setEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.file
- TheFile
data to upload to the webhook.name
- The file name that should be sent to discord
Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...)
for information about this parameter.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided file or filename isnull
.
-
editMessageById
@Nonnull @CheckReturnValue default WebhookMessageUpdateAction<T> editMessageById(long messageId, @Nonnull byte[] data, @Nonnull String name, @Nonnull AttachmentOption... options) Edit an existing message sent by this webhook.
The provided file will be appended to the message. You cannot delete or edit existing files on a message.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext
.Example
WebhookClient hook; // = reference of a WebhookClient such as interaction.getHook() EmbedBuilder embed = new EmbedBuilder(); InputStream file = new FileInputStream("image.png"); // the name in your file system can be different from the name used in discord embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png" .setDescription("This is a cute cat :3"); hook.editMessageById(messageId, file, "cat.png").setEmbeds(embed.build()).queue();
Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The message id. For interactions this supports"@original"
to edit the source message of the interaction.data
- The InputStream data to upload to the webhook.name
- The file name that should be sent to discord
Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...)
for information about this parameter.options
- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
WebhookMessageUpdateAction
- Throws:
IllegalArgumentException
- If the provided data or filename isnull
.
-
deleteMessageById
Delete a message from this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The id for the message to delete- Returns:
RestAction
- Throws:
IllegalArgumentException
- If the provided message id is null or not a valid snowflake
-
deleteMessageById
Delete a message from this webhook.If this is an
InteractionHook
this method will be delayed until the interaction is acknowledged.Possible
ErrorResponses
include:UNKNOWN_WEBHOOK
The webhook is no longer available, either it was deleted or in case of interactions it expired.UNKNOWN_MESSAGE
The message for that id does not exist
- Parameters:
messageId
- The id for the message to delete- Returns:
RestAction
-