Interface WebhookMessageAction<T>

    • Method Detail

      • setEphemeral

        @Nonnull
        @CheckReturnValue
        WebhookMessageAction<T> setEphemeral​(boolean ephemeral)
        Set whether this message should be visible to other users.
        When a message is ephemeral, it will only be visible to the user that used the interaction.

        Ephemeral messages have some limitations and will be removed once the user restarts their client.
        Limitations:

        • Cannot be deleted by the bot
        • Cannot contain any files/attachments
        • Cannot be reacted to
        • Cannot be retrieved

        This only works on InteractionHooks!

        Parameters:
        ephemeral - True, if this message should be invisible for other users
        Returns:
        The same message action, for chaining convenience
      • setContent

        @Nonnull
        @CheckReturnValue
        WebhookMessageAction<T> setContent​(@Nullable
                                           java.lang.String content)
        Set the content for this message.
        Parameters:
        content - The new message content
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided content is longer than MAX_CONTENT_LENGTH characters
      • setTTS

        @Nonnull
        @CheckReturnValue
        WebhookMessageAction<T> setTTS​(boolean tts)
        Enable/Disable Text-To-Speech for the resulting message.
        Parameters:
        tts - True, if this should cause a Text-To-Speech effect when sent to the channel
        Returns:
        The same message action, for chaining convenience
      • addEmbeds

        @Nonnull
        @CheckReturnValue
        WebhookMessageAction<T> addEmbeds​(@Nonnull
                                          java.util.Collection<? extends MessageEmbed> embeds)
        Add MessageEmbeds to this message
        Parameters:
        embeds - The message embeds to add
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided, or one of the embeds is too big
      • addEmbeds

        @Nonnull
        @CheckReturnValue
        default WebhookMessageAction<T> addEmbeds​(@Nonnull
                                                  MessageEmbed embed,
                                                  @Nonnull
                                                  MessageEmbed... other)
        Add MessageEmbeds to this message
        Parameters:
        embed - The first message embed to add
        other - Additional message embeds to add
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided, or one of the embeds is too big
      • addFile

        @Nonnull
        @CheckReturnValue
        WebhookMessageAction<T> addFile​(@Nonnull
                                        java.io.InputStream data,
                                        @Nonnull
                                        java.lang.String name,
                                        @Nonnull
                                        AttachmentOption... options)
        Adds the provided InputStream as file data.
        The stream will be closed upon execution!
        Parameters:
        data - The InputStream that will be interpreted as file data
        name - The file name that should be used to interpret the type of the given data using the file-name extension. This name is similar to what will be visible through Message.Attachment.getFileName()
        options - Possible options to apply to this attachment, such as marking it as spoiler image
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalStateException - If the file limit of 10 has been reached prior to calling this method
        java.lang.IllegalArgumentException - If the provided data is null or the provided name is blank or null
        InsufficientPermissionException - If this is targeting a TextChannel and the currently logged in account does not have Permission.MESSAGE_ATTACH_FILES
      • addFile

        @Nonnull
        @CheckReturnValue
        default WebhookMessageAction<T> addFile​(@Nonnull
                                                byte[] data,
                                                @Nonnull
                                                java.lang.String name,
                                                @Nonnull
                                                AttachmentOption... options)
        Adds the provided byte[] as file data.
        Parameters:
        data - The byte[] that will be interpreted as file data
        name - The file name that should be used to interpret the type of the given data using the file-name extension. This name is similar to what will be visible through Message.Attachment.getFileName()
        options - Possible options to apply to this attachment, such as marking it as spoiler image
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalStateException - If the file limit of 10 has been reached prior to calling this method
        java.lang.IllegalArgumentException - If the provided data is null or the provided name is blank or null or if the provided data exceeds the maximum file size of the currently logged in account
        InsufficientPermissionException - If this is targeting a TextChannel and the currently logged in account does not have Permission.MESSAGE_ATTACH_FILES
        See Also:
        SelfUser.getAllowedFileSize()
      • addFile

        @Nonnull
        @CheckReturnValue
        default WebhookMessageAction<T> addFile​(@Nonnull
                                                java.io.File file,
                                                @Nonnull
                                                java.lang.String name,
                                                @Nonnull
                                                AttachmentOption... options)
        Adds the provided File as file data.
        This method opens a FileInputStream which will be closed by executing this action!
        Parameters:
        file - The File that will be interpreted as file data
        name - The file name that should be used to interpret the type of the given data using the file-name extension. This name is similar to what will be visible through Message.Attachment.getFileName()
        options - Possible options to apply to this attachment, such as marking it as spoiler image
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalStateException - If the file limit of 10 has been reached prior to calling this method
        java.lang.IllegalArgumentException - If the provided file is null or the provided name is blank or null or if the provided file is bigger than the maximum file size of the currently logged in account, or if the provided file does not exist/ is not readable
        InsufficientPermissionException - If this is targeting a TextChannel and the currently logged in account does not have Permission.MESSAGE_ATTACH_FILES
        See Also:
        SelfUser.getAllowedFileSize()
      • addFile

        @Nonnull
        @CheckReturnValue
        default WebhookMessageAction<T> addFile​(@Nonnull
                                                java.io.File file,
                                                @Nonnull
                                                AttachmentOption... options)
        Adds the provided File as file data.
        Shortcut for addFile(file, file.getName()) with the same side-effects.
        Parameters:
        file - The File that will be interpreted as file data
        options - Possible options to apply to this attachment, such as marking it as spoiler image
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalStateException - If the file limit of 10 has been reached prior to calling this method
        java.lang.IllegalArgumentException - If the provided file is null or if the provided File is bigger than the maximum file size of the currently logged in account
        InsufficientPermissionException - If this is targeting a TextChannel and the currently logged in account does not have Permission.MESSAGE_ATTACH_FILES
        See Also:
        SelfUser.getAllowedFileSize()
      • addActionRow

        @Nonnull
        @CheckReturnValue
        default WebhookMessageAction<T> addActionRow​(@Nonnull
                                                     Component... components)
        Add one ActionRow for the message.
        Parameters:
        components - The components for the action row, such as Button
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided or more than 5 actions rows are provided
      • addActionRow

        @Nonnull
        @CheckReturnValue
        default WebhookMessageAction<T> addActionRow​(@Nonnull
                                                     java.util.Collection<? extends Component> components)
        Add one ActionRow for the message.
        Parameters:
        components - The components for the action row, such as Button
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided or more than 5 actions rows are provided
      • addActionRows

        @Nonnull
        @CheckReturnValue
        default WebhookMessageAction<T> addActionRows​(@Nonnull
                                                      java.util.Collection<? extends ActionRow> rows)
        Add ActionRows for the message.
        Parameters:
        rows - The action rows to add
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided or more than 5 actions rows are provided
      • addActionRows

        @Nonnull
        @CheckReturnValue
        WebhookMessageAction<T> addActionRows​(@Nonnull
                                              ActionRow... rows)
        Add ActionRows for the message.
        Parameters:
        rows - The action rows to add
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided or more than 5 actions rows are provided
      • applyMessage

        @Nonnull
        @CheckReturnValue
        WebhookMessageAction<T> applyMessage​(@Nonnull
                                             Message message)
        Applies the sendable information of the provided Message to this message action settings.
        This will override all existing settings if new settings are available.

        This does not copy files!

        Parameters:
        message - The Message to apply settings from
        Returns:
        The same message action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the message contains a MessageEmbed that exceeds the sendable character limit, see MessageEmbed.isSendable()