mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 06:11:55 +00:00
[JDA] Fix User context resolution (#138)
When @ mentioning someone in Discord, if you manually click the user's name then the ID will be in the chat field as "<@!...>". However, one can _also_ mention a user like so "<@...>". This PR handles both cases.
This commit is contained in:
committed by
Daniel Ennis
parent
0499f83e42
commit
3319ab78a2
@@ -68,7 +68,9 @@ public class JDACommandContexts extends CommandContexts<JDACommandExecutionConte
|
||||
}
|
||||
String arg = c.popFirstArg(); // we pop because we are only issuer aware if we are annotated
|
||||
User user = null;
|
||||
if (arg.startsWith("<@")) {
|
||||
if (arg.startsWith("<@!")) { // for some reason a ! is added when @'ing and clicking their name.
|
||||
user = jda.getUserById(arg.substring(3, arg.length() - 1));
|
||||
} else if (arg.startsWith("<@")) { // users can /also/ be mentioned like this...
|
||||
user = jda.getUserById(arg.substring(2, arg.length() - 1));
|
||||
} else {
|
||||
List<User> users = jda.getUsersByName(arg, true);
|
||||
|
||||
Reference in New Issue
Block a user