From fb10a708915f4082218fe2aba11870c137cfb8f6 Mon Sep 17 00:00:00 2001 From: Arnold Alejo Nunag Date: Tue, 15 Sep 2020 01:27:00 +0800 Subject: [PATCH] Add snowflake ids to user argument --- .../janitor/commands/arguments/UserArgument.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/sciwhiz12/janitor/commands/arguments/UserArgument.java b/src/main/java/sciwhiz12/janitor/commands/arguments/UserArgument.java index a843fe8..3d23e9a 100644 --- a/src/main/java/sciwhiz12/janitor/commands/arguments/UserArgument.java +++ b/src/main/java/sciwhiz12/janitor/commands/arguments/UserArgument.java @@ -38,6 +38,17 @@ public class UserArgument implements ArgumentType { 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 { return ImmutableList.of("<@!607058472709652501>", "<@750291676764962816>"); } + private boolean isNumericalCharacter(char c) { + return c >= '0' && c <= '9'; + } + public interface IUserProvider { CompletableFuture getUsers(DiscordApi api); }