Supporting clean installs, broadcast toggles, command improvements #92

Merged
NorbiPeti merged 14 commits from dev into master 2019-03-17 01:31:41 +00:00
3 changed files with 10 additions and 9 deletions
Showing only changes of commit 2b4034b05f - Show all commits

View file

@ -122,6 +122,7 @@ public final class DPUtils {
public static ConfigData<IRole> roleData(IHaveConfig config, String key, String defName, IGuild guild) {
return config.getDataPrimDef(key, defName, name -> {
if (!(name instanceof String)) return null;
val roles = guild.getRolesByName((String) name);
return roles.size() > 0 ? roles.get(0) : null;
}, IIDLinkedObject::getLongID);

View file

@ -22,22 +22,22 @@ import java.util.stream.Collectors;
})
public class UserinfoCommand extends ICommand2DC {
@Command2.Subcommand
public boolean def(Command2DCSender sender, @Command2.OptionalArg String args) {
public boolean def(Command2DCSender sender, @Command2.OptionalArg @Command2.TextArg String user) {
val message = sender.getMessage();
IUser target = null;
if (args == null || args.length() == 0)
if (user == null || user.length() == 0)
target = message.getAuthor();
else {
final Optional<IUser> firstmention = message.getMentions().stream()
.filter(m -> !m.getStringID().equals(DiscordPlugin.dc.getOurUser().getStringID())).findFirst();
if (firstmention.isPresent())
target = firstmention.get();
else if (args.contains("#")) {
String[] targettag = args.split("#");
else if (user.contains("#")) {
String[] targettag = user.split("#");
final List<IUser> targets = getUsers(message, targettag[0]);
if (targets.size() == 0) {
DiscordPlugin.sendMessageToChannel(message.getChannel(),
"The user cannot be found (by name): " + args);
"The user cannot be found (by name): " + user);
return true;
}
for (IUser ptarget : targets) {
@ -48,15 +48,15 @@ public class UserinfoCommand extends ICommand2DC {
}
if (target == null) {
DiscordPlugin.sendMessageToChannel(message.getChannel(),
"The user cannot be found (by discriminator): " + args + "(Found " + targets.size()
"The user cannot be found (by discriminator): " + user + "(Found " + targets.size()
+ " users with the name.)");
return true;
}
} else {
final List<IUser> targets = getUsers(message, args);
final List<IUser> targets = getUsers(message, user);
if (targets.size() == 0) {
DiscordPlugin.sendMessageToChannel(message.getChannel(),
"The user cannot be found on Discord: " + args);
"The user cannot be found on Discord: " + user);
return true;
}
if (targets.size() > 1) {

View file

@ -18,7 +18,7 @@ import lombok.val;
public class MCChatCommand extends ICommand2DC {
@Command2.Subcommand
public boolean def(Command2DCSender sender, String args) {
public boolean def(Command2DCSender sender) {
val message = sender.getMessage();
if (!message.getChannel().isPrivate()) {
message.reply("this command can only be issued in a direct message with the bot.");