Package net.dv8tion.jda.api.requests
Interface RestRateLimiter.Work
- Enclosing interface:
- RestRateLimiter
public static interface RestRateLimiter.Work
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Cancel the request.okhttp3.Responseexecute()Executes the request on the calling thread (blocking).getJDA()The JDA instance which started the request.getRoute()Thecompiled routeof the request.booleanWhether this request was cancelled.booleanisDone()Whether the request is completed.booleanRequests marked as priority should not be cancelled.booleanWhether the request should be skipped.
-
Method Details
-
getRoute
Thecompiled routeof the request.
This is primarily used to handle rate-limit buckets.To correctly handle rate-limits, it is recommended to use the
bucket hashheader from the response.- Returns:
- The
compiled route
-
getJDA
The JDA instance which started the request.- Returns:
- The JDA instance
-
execute
Executes the request on the calling thread (blocking).
This might return null when the request has been skipped while executing. Retries for certain response codes are already handled by this method.After completion, it is advised to use
isDone()to check whether the request should be retried.- Returns:
Responseinstance, used to update the rate-limit data
-
isSkipped
boolean isSkipped()Whether the request should be skipped.
This can be caused by user cancellation.The rate-limiter should handle by simply discarding the task without further action.
- Returns:
- True, if this request is skipped
-
isDone
boolean isDone()Whether the request is completed.
This means you should not try usingexecute()again.- Returns:
- True, if the request has completed.
-
isPriority
boolean isPriority()Requests marked as priority should not be cancelled.- Returns:
- True, if this request is marked as priority
-
isCancelled
boolean isCancelled()Whether this request was cancelled.
Similar toisSkipped(), but only checks cancellation.- Returns:
- True, if this request was cancelled
-
cancel
void cancel()Cancel the request.
Primarily used forJDA.cancelRequests().
-