diff --git a/src/main/java/buttondevteam/discordplugin/commands/UserinfoCommand.java b/src/main/java/buttondevteam/discordplugin/commands/UserinfoCommand.java index 45de66a..7e76975 100644 --- a/src/main/java/buttondevteam/discordplugin/commands/UserinfoCommand.java +++ b/src/main/java/buttondevteam/discordplugin/commands/UserinfoCommand.java @@ -31,7 +31,7 @@ public class UserinfoCommand extends DiscordCommandBase { target = message.getMentions().get(0); else if (args.contains("#")) { String[] targettag = args.split("#"); - final List targets = message.getGuild().getUsersByName(targettag[0], true); + final List targets = getUsers(message, args); if (targets.size() == 0) { DiscordPlugin.sendMessageToChannel(message.getChannel(), "The user cannot be found (by name): " + args); return; @@ -48,12 +48,7 @@ public class UserinfoCommand extends DiscordCommandBase { return; } } else { - final List targets; - if (message.getChannel().isPrivate()) - targets = DiscordPlugin.dc.getUsers().stream().filter(u -> u.getName().equalsIgnoreCase(args)) - .collect(Collectors.toList()); - else - targets = message.getGuild().getUsersByName(args, true); + final List targets = getUsers(message, args); if (targets.size() == 0) { DiscordPlugin.sendMessageToChannel(message.getChannel(), "The user cannot be found on Discord: " + args); @@ -82,6 +77,16 @@ public class UserinfoCommand extends DiscordCommandBase { "The user is not found in our system (player has to be on the MC server for now)!"); } + private List getUsers(IMessage message, String args) { + final List targets; + if (message.getChannel().isPrivate()) + targets = DiscordPlugin.dc.getUsers().stream().filter(u -> u.getName().equalsIgnoreCase(args)) + .collect(Collectors.toList()); + else + targets = message.getGuild().getUsersByName(args, true); + return targets; + } + @Override public String[] getHelpText() { return new String[] { //