Class PlaceholderResolver
The placeholder resolver is used to do simple placeholder/variable resolution. JDA-Commands uses a format similar to project fluent but with some restrictions.
The overall placeholder format is { $your_placeholder }, with following properties:
- the leading
$is optional - whitespace, newlines,
{and$are forbidden inside the reference name - trailing and leading whitespace or newline of the reference name is trimmed (see
String.trim()). - to escape the
{character just prefix it with\\(backslashes can be used unescaped in the rest of the string)
Invalid placeholders will just be treated as literal text.
To get a variables string representation, this resolver:
- calls
Proteus.convert(Object, Type, Type)trying to convert the values toType.of(String.class) - if not successful, just calls
Object.toString()
If a variable couldn't be found, null will be inserted.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintpriority()The priority of this resolver influences the order in which resolver are applied in a resolution pipeline.Resolves the given string according to the class docs.
-
Constructor Details
-
PlaceholderResolver
public PlaceholderResolver()
-
-
Method Details
-
resolve
Resolves the given string according to the class docs. -
priority
public int priority()Description copied from interface:ResolverThe priority of this resolver influences the order in which resolver are applied in a resolution pipeline.
Currently, this only applies to
Resolver<String>, when usingMessageResolver(as JDA-Commands does internally). Generally speaking, resolvers with lower priority run first.If the priority isn't important (e.g. for
ComponentResolver) this should return0.
-