Package net.dv8tion.jda.api.requests
Interface RestRateLimiter.Work
- Enclosing interface:
RestRateLimiter
public static interface RestRateLimiter.Work
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancel the request.okhttp3.Response
execute()
Executes the request on the calling thread (blocking).getJDA()
The JDA instance which started the request.getRoute()
Thecompiled route
of the request.boolean
Whether this request was cancelled.boolean
isDone()
Whether the request is completed.boolean
Requests marked as priority should not be cancelled.boolean
Whether the request should be skipped.
-
Method Details
-
getRoute
Thecompiled route
of the request.
This is primarily used to handle rate-limit buckets.To correctly handle rate-limits, it is recommended to use the
bucket hash
header 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:
Response
instance, 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()
.
-