Interface ReplyAction

    • Method Detail

      • timeout

        @Nonnull
        ReplyAction timeout​(long timeout,
                            @Nonnull
                            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)
      • 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
                                    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:
        IllegalArgumentException - If the provided file is null.
      • addFile

        @Nonnull
        @CheckReturnValue
        default ReplyAction addFile​(@Nonnull
                                    File file,
                                    @Nonnull
                                    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:
        IllegalArgumentException - If the provided file or filename is null.