Interface WebhookClient<T>

    • Method Detail

      • 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 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

        @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 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

        @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:

        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

        @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 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

        @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 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.