Class TriggerRestAction<T>

java.lang.Object
net.dv8tion.jda.internal.requests.RestActionImpl<T>
net.dv8tion.jda.internal.requests.restaction.TriggerRestAction<T>
All Implemented Interfaces:
RestAction<T>
Direct Known Subclasses:
AbstractWebhookMessageActionImpl

public class TriggerRestAction<T> extends RestActionImpl<T>
  • Constructor Details

  • Method Details

    • run

      public void run()
    • fail

      public void fail(Throwable throwable)
    • onReady

      public void onReady(Runnable callback)
    • queue

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