1
0
mirror of https://github.com/sciwhiz12/Janitor.git synced 2024-11-10 05:41:27 +00:00

Allow non-nicknamed mentioned users for user argument

This commit is contained in:
Arnold Alejo Nunag 2020-09-15 00:58:32 +08:00
parent 29b109fcf6
commit 7f91f78a90
Signed by: sciwhiz12
GPG Key ID: 622CF446534317E1

View File

@ -17,7 +17,7 @@ import java.util.regex.Pattern;
public class UserArgument implements ArgumentType<UserArgument.IUserProvider> { public class UserArgument implements ArgumentType<UserArgument.IUserProvider> {
public static final SimpleCommandExceptionType UNKNOWN_USER_IDENTIFIER = new SimpleCommandExceptionType(new LiteralMessage("Unknown user identifier")); public static final SimpleCommandExceptionType UNKNOWN_USER_IDENTIFIER = new SimpleCommandExceptionType(new LiteralMessage("Unknown user identifier"));
public static final Pattern USER_IDENTIFIER_PATTERN = Pattern.compile("<@!([0-9]+)>"); public static final Pattern USER_IDENTIFIER_PATTERN = Pattern.compile("<@!?([0-9]+)>");
public static UserArgument user() { public static UserArgument user() {
return new UserArgument(); return new UserArgument();
@ -29,6 +29,7 @@ public class UserArgument implements ArgumentType<UserArgument.IUserProvider> {
@Override @Override
public IUserProvider parse(StringReader reader) throws CommandSyntaxException { public IUserProvider parse(StringReader reader) throws CommandSyntaxException {
int startCursor = reader.getCursor();
if (reader.peek() == '<') { // Expecting a possible user identifier if (reader.peek() == '<') { // Expecting a possible user identifier
int start = reader.getCursor(); int start = reader.getCursor();
reader.readStringUntil('>'); reader.readStringUntil('>');