Interface ReplyAction

    • Method Detail

      • setCheck

        @Nonnull
        ReplyAction setCheck​(@Nullable
                             java.util.function.BooleanSupplier checks)
        Description copied from interface: RestAction
        Sets the last-second checks before finally executing the http request in the queue.
        If the provided supplier evaluates to false or throws an exception this will not be finished. When an exception is thrown from the supplier it will be provided to the failure callback.
        Specified by:
        setCheck in interface RestAction<InteractionHook>
        Parameters:
        checks - The checks to run before executing the request, or null to run no checks
        Returns:
        The current RestAction for chaining convenience
        See Also:
        RestAction.getCheck(), RestAction.addCheck(BooleanSupplier)
      • timeout

        @Nonnull
        ReplyAction timeout​(long timeout,
                            @Nonnull
                            java.util.concurrent.TimeUnit unit)
        Description copied from interface: RestAction
        Timeout for this RestAction instance.
        If the request doesn't get executed within the timeout it will fail.

        When a RestAction times out, it will fail with a TimeoutException. This is the same as deadline(System.currentTimeMillis() + unit.toMillis(timeout)).

        Example

        
         action.timeout(10, TimeUnit.SECONDS) // 10 seconds from now
               .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
         
        Specified by:
        timeout in interface RestAction<InteractionHook>
        Parameters:
        timeout - The timeout to use
        unit - Unit for the timeout value
        Returns:
        The same RestAction instance with the applied timeout
        See Also:
        RestAction.setDefaultTimeout(long, TimeUnit)
      • deadline

        @Nonnull
        ReplyAction deadline​(long timestamp)
        Description copied from interface: RestAction
        Similar to RestAction.timeout(long, TimeUnit) but schedules a deadline at which the request has to be completed.
        If the deadline is reached, the request will fail with a TimeoutException.

        This does not mean that the request will immediately timeout when the deadline is reached. JDA will check the deadline right before executing the request or within intervals in a worker thread. This only means the request will timeout if the deadline has passed.

        Example

        
         action.deadline(System.currentTimeMillis() + 10000) // 10 seconds from now
               .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
         
        Specified by:
        deadline in interface RestAction<InteractionHook>
        Parameters:
        timestamp - Millisecond timestamp at which the request will timeout
        Returns:
        The same RestAction with the applied deadline
        See Also:
        RestAction.timeout(long, TimeUnit), RestAction.setDefaultTimeout(long, TimeUnit)
      • addEmbeds

        @Nonnull
        @CheckReturnValue
        default ReplyAction addEmbeds​(@Nonnull
                                      MessageEmbed... embeds)
        Add MessageEmbeds for the message
        Parameters:
        embeds - The message embeds to add
        Returns:
        The same reply action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided, or one of the embeds is too big
      • addEmbeds

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

        @Nonnull
        @CheckReturnValue
        default ReplyAction addActionRow​(@Nonnull
                                         Component... components)
        Add a single ActionRow to the message.
        Parameters:
        components - The components for this action row
        Returns:
        The same reply action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided or an invalid number of components are provided
        See Also:
        ActionRow.of(Component...)
      • addActionRow

        @Nonnull
        @CheckReturnValue
        default ReplyAction addActionRow​(@Nonnull
                                         java.util.Collection<? extends Component> components)
        Add a single ActionRow to the message.
        Parameters:
        components - The components for this action row
        Returns:
        The same reply action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided or an invalid number of components are provided
        See Also:
        ActionRow.of(Collection)
      • addActionRows

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

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

        @Nonnull
        ReplyAction setContent​(@Nullable
                               java.lang.String content)
        Set the content for this message.
        Parameters:
        content - The new message content or null to unset
        Returns:
        The same reply action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided content is longer than MAX_CONTENT_LENGTH characters
      • setTTS

        @Nonnull
        ReplyAction setTTS​(boolean isTTS)
        Enable/Disable Text-To-Speech for the resulting message.
        Parameters:
        isTTS - True, if this should cause a Text-To-Speech effect when sent to the channel
        Returns:
        The same reply action, for chaining convenience
      • setEphemeral

        @Nonnull
        @CheckReturnValue
        ReplyAction 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
        Parameters:
        ephemeral - True, if this message should be invisible for other users
        Returns:
        The same reply action, for chaining convenience
      • addFile

        @Nonnull
        @CheckReturnValue
        default ReplyAction addFile​(@Nonnull
                                    java.io.File file,
                                    @Nonnull
                                    AttachmentOption... options)
        Adds the provided File.
        The stream will be closed upon execution!
        The provided file will be appended to the message.
        Parameters:
        file - The File data to upload in response to the interaction.
        options - Possible options to apply to this attachment, such as marking it as spoiler image
        Returns:
        The same reply action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided file is null.
      • addFile

        @Nonnull
        @CheckReturnValue
        default ReplyAction addFile​(@Nonnull
                                    java.io.File file,
                                    @Nonnull
                                    java.lang.String name,
                                    @Nonnull
                                    AttachmentOption... options)
        Adds the provided File.
        The stream will be closed upon execution!
        The provided file will be appended to the message.

        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.
        Parameters:
        file - The File data to upload in response to the interaction.
        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:
        The same reply action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided file or filename is null.
      • addFile

        @Nonnull
        @CheckReturnValue
        default ReplyAction addFile​(@Nonnull
                                    byte[] data,
                                    @Nonnull
                                    java.lang.String name,
                                    @Nonnull
                                    AttachmentOption... options)
        Adds the provided byte[] as file data.
        The stream will be closed upon execution!
        The provided file will be appended to the message.
        Parameters:
        data - The byte[] data to upload in response to the interaction.
        name - The file name that should be sent to discord
        Refer to the documentation for addFile(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:
        The same reply action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided data or filename is null.
      • addFile

        @Nonnull
        @CheckReturnValue
        ReplyAction 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!
        The provided file will be appended to the message.
        Parameters:
        data - The InputStream data to upload in response to the interaction.
        name - The file name that should be sent to discord
        Refer to the documentation for addFile(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:
        The same reply action, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided data or filename is null.