Fixed userinfo command in PM

This commit is contained in:
Norbi Peti 2016-11-05 19:46:14 +01:00
parent 73280fa88e
commit b144a55935
2 changed files with 7 additions and 4 deletions

View file

@ -49,9 +49,6 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
lastannouncementtime = getConfig().getLong("lastannouncementtime"); lastannouncementtime = getConfig().getLong("lastannouncementtime");
lastseentime = getConfig().getLong("lastseentime"); lastseentime = getConfig().getLong("lastseentime");
Test = getConfig().getBoolean("test", true); Test = getConfig().getBoolean("test", true);
getConfig().set("lastannouncementtime", lastannouncementtime);
getConfig().set("lastseentime", lastseentime);
getConfig().set("test", Test); // TODO: TMP
saveConfig(); saveConfig();
} }
ClientBuilder cb = new ClientBuilder(); ClientBuilder cb = new ClientBuilder();

View file

@ -1,6 +1,7 @@
package buttondevteam.discordplugin.commands; package buttondevteam.discordplugin.commands;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import buttondevteam.discordplugin.DiscordPlayer; import buttondevteam.discordplugin.DiscordPlayer;
import buttondevteam.discordplugin.DiscordPlugin; import buttondevteam.discordplugin.DiscordPlugin;
@ -47,7 +48,12 @@ public class UserinfoCommand extends DiscordCommandBase {
return; return;
} }
} else { } else {
final List<IUser> targets = message.getGuild().getUsersByName(args, true); final List<IUser> 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);
if (targets.size() == 0) { if (targets.size() == 0) {
DiscordPlugin.sendMessageToChannel(message.getChannel(), DiscordPlugin.sendMessageToChannel(message.getChannel(),
"The user cannot be found on Discord: " + args); "The user cannot be found on Discord: " + args);