1
0
mirror of https://github.com/sciwhiz12/Janitor.git synced 2024-11-10 03:21:26 +00:00

Add snowflake ids to user argument

This commit is contained in:
Arnold Alejo Nunag 2020-09-15 01:27:00 +08:00
parent 7f91f78a90
commit fb10a70891
Signed by: sciwhiz12
GPG Key ID: 622CF446534317E1

View File

@ -38,6 +38,17 @@ public class UserArgument implements ArgumentType<UserArgument.IUserProvider> {
return new NumericalProvider(Long.parseLong(matcher.group(1)));
}
}
reader.setCursor(startCursor);
CommandSyntaxException idReadException = null;
if (StringReader.isAllowedNumber(reader.peek())) {
try {
long value = reader.readLong();
return new NumericalProvider(value);
} catch (CommandSyntaxException e) {
idReadException = e;
}
}
if (idReadException != null) throw idReadException;
throw UNKNOWN_USER_IDENTIFIER.create();
}
@ -46,6 +57,10 @@ public class UserArgument implements ArgumentType<UserArgument.IUserProvider> {
return ImmutableList.of("<@!607058472709652501>", "<@750291676764962816>");
}
private boolean isNumericalCharacter(char c) {
return c >= '0' && c <= '9';
}
public interface IUserProvider {
CompletableFuture<User> getUsers(DiscordApi api);
}