Interface WebhookClient<T>

All Known Subinterfaces:
InteractionHook

public interface WebhookClient<T>
Interface which allows sending messages through the webhooks API.
Interactions can use these through IDeferrableCallback.getHook().
See Also:
  • 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 than Message.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 content
      args - Format arguments for the content
      Returns:
      WebhookMessageAction
      Throws:
      IllegalArgumentException - If the format string is null or the resulting content is longer than Message.MAX_CONTENT_LENGTH
    • sendMessageEmbeds

      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 than MessageEmbed.EMBED_MAX_LENGTH_BOT.
    • sendMessageEmbeds

      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 use
      embeds - Additional MessageEmbeds to use (up to 10 in total)
      Returns:
      WebhookMessageAction
      Throws:
      IllegalArgumentException - If any of the embeds are null, more than 10, or longer than MessageEmbed.EMBED_MAX_LENGTH_BOT.
    • sendFile

      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 URI attachment://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:

      Parameters:
      data - The InputStream data to upload to the webhook.
      name - The file name that should be sent to discord
      Refer to the documentation for sendFile(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 is null or empty.
    • sendFile

      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 using File.getName().

      sendFile(file, file.getName())

      Uploading images with Embeds
      When uploading an image you can reference said image using the specified filename as URI attachment://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:

      Parameters:
      file - The File 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 is null.
    • sendFile

      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:

      1. 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.
      2. 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 URI attachment://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:

      Parameters:
      file - The File data to upload to the webhook.
      name - The file name that should be sent to discord
      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 is null or empty.
    • 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 URI attachment://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:

      Parameters:
      data - The byte[] data to upload to the webhook.
      name - The file name that should be sent to discord
      Refer to the documentation for sendFile(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 is null or empty.
    • editMessageById

      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 than Message.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 than Message.MAX_CONTENT_LENGTH
    • editMessageById

      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 content
      args - Format arguments for the content
      Returns:
      WebhookMessageUpdateAction
      Throws:
      IllegalArgumentException - If the formatted string is null, empty, or longer than Message.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 content
      args - Format arguments for the content
      Returns:
      WebhookMessageUpdateAction
      Throws:
      IllegalArgumentException - If the formatted string is null, empty, or longer than Message.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 new MessageEmbeds 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 new MessageEmbeds 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 as ActionRows
      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 as ActionRows
      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 as ActionRows
      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 as ActionRows
      Returns:
      WebhookMessageUpdateAction
      Throws:
      IllegalArgumentException - If the provided components are null, or more than 5 layouts are provided
    • editMessageById

      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 URI attachment://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 for sendFile(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 is null.
    • 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 using File.getName().

      editMessageById(messageId, file, file.getName())

      Uploading images with Embeds
      When uploading an image you can reference said image using the specified filename as URI attachment://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 - The File 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 is null.
    • editMessageById

      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 URI attachment://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 - The File data to upload to the webhook.
      name - The file name that should be sent to discord
      Refer to the documentation for sendFile(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 is null.
    • 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 URI attachment://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 for sendFile(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 is null.
    • 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 URI attachment://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 for sendFile(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 is null.
    • 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 using File.getName().

      sendFile(file, file.getName())

      Uploading images with Embeds
      When uploading an image you can reference said image using the specified filename as URI attachment://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 - The File 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 is null.
    • 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 URI attachment://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 - The File data to upload to the webhook.
      name - The file name that should be sent to discord
      Refer to the documentation for sendFile(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 is null.
    • 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 URI attachment://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 for sendFile(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 is null.
    • deleteMessageById

      @Nonnull @CheckReturnValue RestAction<Void> deleteMessageById(@Nonnull String messageId)
      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

      @Nonnull @CheckReturnValue default RestAction<Void> deleteMessageById(long messageId)
      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