Class Route
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classclassA route compiled with arguments.static classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionThe known major parameters used for rate-limits. -
Method Summary
Modifier and TypeMethodDescriptionCompile the route with provided parameters.static RouteCreate a route template for the given HTTP method.static RouteCreate a route template for the with theDELETEmethod.booleanstatic RouteCreate a route template for the with theGETmethod.TheMethodof this route template.intThe number of parameters for this route, not including query parameters.getRoute()The route template with argument placeholders.inthashCode()booleanWhether this route is a route related to interactions.static RouteCreate a route template for the with thePATCHmethod.static RouteCreate a route template for the with thePOSTmethod.static RouteCreate a route template for the with thePUTmethod.toString()
-
Field Details
-
MAJOR_PARAMETER_NAMES
The known major parameters used for rate-limits.Instead of
webhook_id + webhook_token, we useinteraction_tokenfor interaction routes.- See Also:
-
-
Method Details
-
custom
Create a route template for the given HTTP method.Route syntax should include valid argument placeholders of the format:
'{' argument_name '}'
The rate-limit handling in JDA relies on the correct names of major parameters:channel_idfor channel routesguild_idfor guild routeswebhook_idfor webhook routesinteraction_tokenfor interaction routes
Route route = Route.custom(Method.POST, "channels/{channel_id}/messages");To compile the route, use
compile(String...)with the positional arguments.Route.CompiledRoute compiled = route.compile(channelId);- Parameters:
method- The HTTP methodroute- The route template with valid argument placeholders- Returns:
- The custom route template
- Throws:
IllegalArgumentException- If null is provided or the route is invalid (containing spaces or empty)
-
delete
Create a route template for the with theDELETEmethod.Route syntax should include valid argument placeholders of the format:
'{' argument_name '}'
The rate-limit handling in JDA relies on the correct names of major parameters:channel_idfor channel routesguild_idfor guild routeswebhook_idfor webhook routesinteraction_tokenfor interaction routes
Route route = Route.custom(Method.DELETE, "channels/{channel_id}/messages/{message_id}");To compile the route, use
compile(String...)with the positional arguments.Route.CompiledRoute compiled = route.compile(channelId, messageId);- Parameters:
route- The route template with valid argument placeholders- Returns:
- The custom route template
- Throws:
IllegalArgumentException- If null is provided or the route is invalid (containing spaces or empty)
-
post
Create a route template for the with thePOSTmethod.Route syntax should include valid argument placeholders of the format:
'{' argument_name '}'
The rate-limit handling in JDA relies on the correct names of major parameters:channel_idfor channel routesguild_idfor guild routeswebhook_idfor webhook routesinteraction_tokenfor interaction routes
Route route = Route.custom(Method.POST, "channels/{channel_id}/messages");To compile the route, use
compile(String...)with the positional arguments.Route.CompiledRoute compiled = route.compile(channelId);- Parameters:
route- The route template with valid argument placeholders- Returns:
- The custom route template
- Throws:
IllegalArgumentException- If null is provided or the route is invalid (containing spaces or empty)
-
put
Create a route template for the with thePUTmethod.Route syntax should include valid argument placeholders of the format:
'{' argument_name '}'
The rate-limit handling in JDA relies on the correct names of major parameters:channel_idfor channel routesguild_idfor guild routeswebhook_idfor webhook routesinteraction_tokenfor interaction routes
Route route = Route.custom(Method.PUT, "guilds/{guild_id}/bans/{user_id}");To compile the route, use
compile(String...)with the positional arguments.Route.CompiledRoute compiled = route.compile(guildId, userId);- Parameters:
route- The route template with valid argument placeholders- Returns:
- The custom route template
- Throws:
IllegalArgumentException- If null is provided or the route is invalid (containing spaces or empty)
-
patch
Create a route template for the with thePATCHmethod.Route syntax should include valid argument placeholders of the format:
'{' argument_name '}'
The rate-limit handling in JDA relies on the correct names of major parameters:channel_idfor channel routesguild_idfor guild routeswebhook_idfor webhook routesinteraction_tokenfor interaction routes
Route route = Route.custom(Method.PATCH, "channels/{channel_id}/messages/{message_id}");To compile the route, use
compile(String...)with the positional arguments.Route.CompiledRoute compiled = route.compile(channelId, messageId);- Parameters:
route- The route template with valid argument placeholders- Returns:
- The custom route template
- Throws:
IllegalArgumentException- If null is provided or the route is invalid (containing spaces or empty)
-
get
Create a route template for the with theGETmethod.Route syntax should include valid argument placeholders of the format:
'{' argument_name '}'
The rate-limit handling in JDA relies on the correct names of major parameters:channel_idfor channel routesguild_idfor guild routeswebhook_idfor webhook routesinteraction_tokenfor interaction routes
Route route = Route.custom(Method.GET, "channels/{channel_id}/messages/{message_id}");To compile the route, use
compile(String...)with the positional arguments.Route.CompiledRoute compiled = route.compile(channelId, messageId);- Parameters:
route- The route template with valid argument placeholders- Returns:
- The custom route template
- Throws:
IllegalArgumentException- If null is provided or the route is invalid (containing spaces or empty)
-
isInteractionBucket
public boolean isInteractionBucket()Whether this route is a route related to interactions.
Interactions have some special handling, since they are exempt from global rate-limits and are limited to 15 minute uptime.- Returns:
- True, if this route is for interactions
-
getMethod
TheMethodof this route template.
Multiple routes with different HTTP methods can share a rate-limit.- Returns:
- The HTTP method
-
getRoute
The route template with argument placeholders.- Returns:
- The route template
-
getParamCount
public int getParamCount()The number of parameters for this route, not including query parameters.- Returns:
- The parameter count
-
compile
Compile the route with provided parameters.
The number of parameters must match the number of placeholders in the route template. The provided arguments are positional and will replace the placeholders of the template in order of appearance.Use
Route.CompiledRoute.withQueryParams(String...)to add query parameters to the route.- Parameters:
params- The parameters to compile the route with- Returns:
- The compiled route, ready to use for rate-limit handling
- Throws:
IllegalArgumentException- If the number of parameters does not match the number of placeholders, or null is provided
-
hashCode
public int hashCode() -
equals
-
toString
-