Made @ChromaBot not count as mentioning

This commit is contained in:
Norbi Peti 2016-12-02 21:19:12 +01:00
parent e4871b2785
commit 95ab347ef6

View file

@ -2,6 +2,7 @@ package buttondevteam.discordplugin.commands;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import buttondevteam.discordplugin.DiscordPlayer; import buttondevteam.discordplugin.DiscordPlayer;
import buttondevteam.discordplugin.DiscordPlugin; import buttondevteam.discordplugin.DiscordPlugin;
@ -27,13 +28,17 @@ public class UserinfoCommand extends DiscordCommandBase {
IUser target = null; IUser target = null;
if (args.length() == 0) if (args.length() == 0)
target = message.getAuthor(); target = message.getAuthor();
else if (message.getMentions().size() > 0) else {
target = message.getMentions().get(0); final Stream<IUser> mentions = message.getMentions().stream()
.filter(m -> !m.getID().equals(DiscordPlugin.dc.getOurUser().getID()));
if (mentions.findFirst().isPresent())
target = mentions.findFirst().get();
else if (args.contains("#")) { else if (args.contains("#")) {
String[] targettag = args.split("#"); String[] targettag = args.split("#");
final List<IUser> targets = getUsers(message, targettag[0]); final List<IUser> targets = getUsers(message, targettag[0]);
if (targets.size() == 0) { if (targets.size() == 0) {
DiscordPlugin.sendMessageToChannel(message.getChannel(), "The user cannot be found (by name): " + args); DiscordPlugin.sendMessageToChannel(message.getChannel(),
"The user cannot be found (by name): " + args);
return; return;
} }
for (IUser ptarget : targets) { for (IUser ptarget : targets) {
@ -43,8 +48,9 @@ public class UserinfoCommand extends DiscordCommandBase {
} }
} }
if (target == null) { if (target == null) {
DiscordPlugin.sendMessageToChannel(message.getChannel(), "The user cannot be found (by discriminator): " DiscordPlugin.sendMessageToChannel(message.getChannel(),
+ args + "(Found " + targets.size() + " users with the name.)"); "The user cannot be found (by discriminator): " + args + "(Found " + targets.size()
+ " users with the name.)");
return; return;
} }
} else { } else {
@ -61,6 +67,7 @@ public class UserinfoCommand extends DiscordCommandBase {
} }
target = targets.get(0); target = targets.get(0);
} }
}
boolean found = false; boolean found = false;
for (TBMCPlayer player : TBMCPlayer.getLoadedPlayers().values()) { for (TBMCPlayer player : TBMCPlayer.getLoadedPlayers().values()) {
DiscordPlayer dp = player.asPluginPlayer(DiscordPlayer.class); DiscordPlayer dp = player.asPluginPlayer(DiscordPlayer.class);