Class Route
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
class
A route compiled with arguments.static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
-
Field Summary
Modifier and TypeFieldDescriptionThe known major parameters used for rate-limits. -
Method Summary
Modifier and TypeMethodDescriptionCompile the route with provided parameters.static Route
Create a route template for the given HTTP method.static Route
Create a route template for the with theDELETE
method.boolean
static Route
Create a route template for the with theGET
method.TheMethod
of this route template.int
The number of parameters for this route, not including query parameters.getRoute()
The route template with argument placeholders.int
hashCode()
boolean
Whether this route is a route related to interactions.static Route
Create a route template for the with thePATCH
method.static Route
Create a route template for the with thePOST
method.static Route
Create a route template for the with thePUT
method.toString()
-
Field Details
-
MAJOR_PARAMETER_NAMES
The known major parameters used for rate-limits.Instead of
webhook_id + webhook_token
, we useinteraction_token
for 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_id
for channel routesguild_id
for guild routeswebhook_id
for webhook routesinteraction_token
for 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 theDELETE
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_id
for channel routesguild_id
for guild routeswebhook_id
for webhook routesinteraction_token
for 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 thePOST
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_id
for channel routesguild_id
for guild routeswebhook_id
for webhook routesinteraction_token
for 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 thePUT
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_id
for channel routesguild_id
for guild routeswebhook_id
for webhook routesinteraction_token
for 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 thePATCH
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_id
for channel routesguild_id
for guild routeswebhook_id
for webhook routesinteraction_token
for 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 theGET
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_id
for channel routesguild_id
for guild routeswebhook_id
for webhook routesinteraction_token
for 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
TheMethod
of 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
-