Class MentionableParser<E extends Entity>
java.lang.Object
dev.sympho.modular_commands.utils.parse.EntityParser<E>
dev.sympho.modular_commands.utils.parse.MentionableParser<E>
- Type Parameters:
E- The entity type.
- All Implemented Interfaces:
ParserFunction<String,,E> BiFunction<CommandContext,String, Mono<E>>
- Direct Known Subclasses:
ChannelParser,RoleParser,UserParser
A parser that extracts a mentionable entity 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 TypeMethodDescriptionParses the entity ID from the raw argument.abstract StringparseMention(String mention) Parses the entity ID from a text mention.parseMention(String mention, String prefix) Parses the entity ID from a text mention.Methods inherited from class dev.sympho.modular_commands.utils.parse.EntityParser
getEntity, getUrlParser, parse, 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
-
MentionableParser
public MentionableParser()
-
-
Method Details
-
parseMention
@SideEffectFree public static Optional<String> parseMention(String mention, String prefix) throws InvalidArgumentException Parses the entity ID from a text mention.- Parameters:
mention- The text mention.prefix- The prefix that identifies a mention.- Returns:
- The ID in the mention.
- Throws:
InvalidArgumentException- if the mention was invalid.
-
parseMention
Parses the entity ID from a text mention.- Parameters:
mention- The text mention.- Returns:
- The ID in the mention.
- Throws:
InvalidArgumentException- if the mention was invalid.
-
extractId
Description copied from class:EntityParserParses the entity ID from the raw argument.- Overrides:
extractIdin classEntityParser<E extends Entity>- Parameters:
raw- The received argument.- Returns:
- The entity ID.
- Throws:
InvalidArgumentException- if the given string is not a valid ID.- Implementation Requirements:
- Supports both plain IDs and mentions by default.
-