Class InteractionCallbackImpl<T>

java.lang.Object
net.dv8tion.jda.internal.requests.RestActionImpl<T>
net.dv8tion.jda.internal.requests.restaction.interactions.InteractionCallbackImpl<T>
All Implemented Interfaces:
RestAction<T>, InteractionCallbackAction<T>
Direct Known Subclasses:
AutoCompleteCallbackActionImpl, DeferrableCallbackActionImpl, ModalCallbackActionImpl

public abstract class InteractionCallbackImpl<T> extends RestActionImpl<T> implements InteractionCallbackAction<T>
  • Constructor Details

    • InteractionCallbackImpl

      public InteractionCallbackImpl(InteractionImpl interaction)
  • Method Details

    • closeResources

      @Nonnull public InteractionCallbackAction<T> closeResources()
      Description copied from interface: InteractionCallbackAction
      Closes all owned resources used for this request.

      This closes all files added, if applicable.

      Specified by:
      closeResources in interface InteractionCallbackAction<T>
      Returns:
      This instance for chaining.
    • queue

      public final void queue(Consumer<? super T> success, Consumer<? super Throwable> failure)
      Description copied from interface: RestAction
      Submits a Request for execution.

      This method is asynchronous

      Example

      
       public static void sendPrivateMessage(JDA jda, String userId, String content)
       {
           // Retrieve the user by their id
           RestAction<User> action = jda.retrieveUserById(userId);
           action.queue(
               // Handle success if the user exists
               (user) -> user.openPrivateChannel().queue(
                   (channel) -> channel.sendMessage(content).queue()),
      
               // Handle failure if the user does not exist (or another issue appeared)
               (error) -> error.printStackTrace()
           );
      
           // Alternatively use submit() to remove nested callbacks
       }
       
      Specified by:
      queue in interface RestAction<T>
      Overrides:
      queue in class RestActionImpl<T>
      Parameters:
      success - The success callback that will be called at a convenient time for the API. (can be null to use default)
      failure - The failure callback that will be called if the Request encounters an exception at its execution point. (can be null to use default)
      See Also:
    • submit

      @Nonnull public final CompletableFuture<T> submit(boolean shouldQueue)
      Description copied from interface: RestAction
      Submits a Request for execution and provides a CompletableFuture representing its completion task.
      Cancelling the returned Future will result in the cancellation of the Request!
      Specified by:
      submit in interface RestAction<T>
      Overrides:
      submit in class RestActionImpl<T>
      Parameters:
      shouldQueue - Whether the Request should automatically handle rate limitations. (default true)
      Returns:
      Never-null CompletableFuture task representing the completion promise
    • handleResponse

      public void handleResponse(Response response, Request<T> request)
      Overrides:
      handleResponse in class RestActionImpl<T>