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
-
Field Summary
Fields inherited from class net.dv8tion.jda.internal.requests.RestActionImpl
LOG
-
Constructor Summary
ConstructorsConstructorDescriptionTriggerRestAction
(JDA api, Route.CompiledRoute route) TriggerRestAction
(JDA api, Route.CompiledRoute route, BiFunction<Response, Request<T>, T> handler) TriggerRestAction
(JDA api, Route.CompiledRoute route, DataObject data) TriggerRestAction
(JDA api, Route.CompiledRoute route, DataObject data, BiFunction<Response, Request<T>, T> handler) TriggerRestAction
(JDA api, Route.CompiledRoute route, okhttp3.RequestBody data) TriggerRestAction
(JDA api, Route.CompiledRoute route, okhttp3.RequestBody data, BiFunction<Response, Request<T>, T> handler) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
Submits a Request for execution.void
run()
submit
(boolean shouldQueue) Submits a Request for execution and provides aCompletableFuture
representing its completion task.Methods inherited from class net.dv8tion.jda.internal.requests.RestActionImpl
complete, deadline, getCheck, getDefaultFailure, getDefaultSuccess, getDefaultTimeout, getJDA, handleResponse, isPassContext, priority, setCheck, setDefaultFailure, setDefaultSuccess, setDefaultTimeout, setErrorMapper, setPassContext
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
addCheck, and, and, complete, completeAfter, delay, delay, delay, delay, flatMap, flatMap, map, mapToResult, onErrorFlatMap, onErrorFlatMap, onErrorMap, onErrorMap, onSuccess, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submitAfter, submitAfter, timeout, zip
-
Constructor Details
-
TriggerRestAction
-
TriggerRestAction
-
TriggerRestAction
-
TriggerRestAction
public TriggerRestAction(JDA api, Route.CompiledRoute route, BiFunction<Response, Request<T>, T> handler) -
TriggerRestAction
public TriggerRestAction(JDA api, Route.CompiledRoute route, DataObject data, BiFunction<Response, Request<T>, T> handler) -
TriggerRestAction
public TriggerRestAction(JDA api, Route.CompiledRoute route, okhttp3.RequestBody data, BiFunction<Response, Request<T>, T> handler)
-
-
Method Details
-
run
public void run() -
fail
-
onReady
-
queue
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 interfaceRestAction<T>
- Overrides:
queue
in classRestActionImpl<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
Description copied from interface:RestAction
Submits a Request for execution and provides aCompletableFuture
representing its completion task.
Cancelling the returned Future will result in the cancellation of the Request!- Specified by:
submit
in interfaceRestAction<T>
- Overrides:
submit
in classRestActionImpl<T>
- Parameters:
shouldQueue
- Whether the Request should automatically handle rate limitations. (default true)- Returns:
- Never-null
CompletableFuture
task representing the completion promise
-