Class RoleParser
java.lang.Object
dev.sympho.modular_commands.utils.parse.EntityParser<E>
dev.sympho.modular_commands.utils.parse.MentionableParser<Role>
dev.sympho.modular_commands.utils.parse.RoleParser
- All Implemented Interfaces:
ParserFunction<String,,Role> BiFunction<CommandContext,String, Mono<Role>>
A parser that extracts a role from a string.
- Since:
- 1.0
- Version:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ParserFunction
ParserFunction.PostParser<R extends @NonNull Object,I extends @NonNull Object, T extends @NonNull Object, P1 extends @NonNull ParserFunction<R, I>, P2 extends @NonNull ParserFunction<I, T>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetEntity(CommandContext context, Snowflake id) Retrieves the entity with the given ID.parse(CommandContext context, String raw) Parses the given raw argument from the user into the corresponding value.parseMention(String mention) Parses the entity ID from a text mention.Methods inherited from class dev.sympho.modular_commands.utils.parse.MentionableParser
extractId, parseMentionMethods inherited from class dev.sympho.modular_commands.utils.parse.EntityParser
getUrlParser, parseIdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.function.BiFunction
andThenMethods inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ParserFunction
apply, then
-
Constructor Details
-
RoleParser
public RoleParser()Creates a new instance.
-
-
Method Details
-
getEntity
Description copied from class:EntityParserRetrieves the entity with the given ID.- Specified by:
getEntityin classEntityParser<Role>- Parameters:
context- The execution context.id- The entity ID.- Returns:
- The entity. May be empty if not found.
-
parseMention
Description copied from class:MentionableParserParses the entity ID from a text mention.- Specified by:
parseMentionin classMentionableParser<Role>- Parameters:
mention- The text mention.- Returns:
- The ID in the mention.
- Throws:
InvalidArgumentException- if the mention was invalid.
-
parse
Description copied from interface:ParserFunctionParses the given raw argument from the user into the corresponding value.- Specified by:
parsein interfaceParserFunction<String,Role> - Overrides:
parsein classEntityParser<Role>- Parameters:
context- The execution context.raw- The raw argument received from the user.- Returns:
- A Mono that issues the parsed argument. If the raw value is invalid, it may
fail with a
InvalidArgumentException. May be empty, in which case the value defers to thedefault(functionally the same as if the argument was missing, but without causing an error if the parameter isrequired). - Throws:
InvalidArgumentException- if the given argument is not a valid value.
-