This commit is contained in:
@@ -17,43 +17,49 @@ public class AliasCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Arrays.asList("alias", "aliases"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null; // anyone can use it
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.TOOLS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "See other command aliases.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "<command>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||
{
|
||||
if(args.length == 0)
|
||||
if (args.length == 0)
|
||||
{
|
||||
event.getMessage().reply("\uD83D\uDE20 Hey, you have to specify a command!").queue();
|
||||
return;
|
||||
@@ -61,14 +67,14 @@ public class AliasCommand implements MessageCommand
|
||||
|
||||
String commandLabel = args[0].toLowerCase();
|
||||
MessageCommand command = Cache.getMessageCommandListener().getRegisteredCommand(commandLabel);
|
||||
if(command == null)
|
||||
if (command == null)
|
||||
{
|
||||
event.getMessage().reply("Unrecognized command: `" + commandLabel + "`!").queue(); // todo prettier
|
||||
return;
|
||||
}
|
||||
|
||||
String aliases = Alias.generateNiceAliases(command);
|
||||
aliases = "Aliases for **" + command.getCommandLabels().get(0) + "**: " + aliases;
|
||||
aliases = "Aliases for **" + command.getCommandLabels().get(0) + "**: " + aliases;
|
||||
|
||||
event.getMessage()
|
||||
.reply(aliases)
|
||||
|
||||
@@ -16,40 +16,46 @@ import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class AvatarCommand implements MessageCommand
|
||||
public class AvatarCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Collections.singletonList("avatar"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null; // anyone can use it
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Get someone's avatar, or your own. You can additionally specify a resolution.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "[mentioned user] [resolution]";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.TOOLS;
|
||||
}
|
||||
|
||||
@@ -63,23 +69,26 @@ public class AvatarCommand implements MessageCommand
|
||||
// (mentions are handled differently by a specific method)
|
||||
boolean resFound = false;
|
||||
|
||||
for (String arg : args) {
|
||||
try {
|
||||
for (String arg : args)
|
||||
{
|
||||
try
|
||||
{
|
||||
int givenRes = Integer.parseInt(arg);
|
||||
resolution = ProfileImage.parseResolution(givenRes);
|
||||
resFound = true;
|
||||
break;
|
||||
} catch (NumberFormatException ignored) {
|
||||
} catch (NumberFormatException ignored)
|
||||
{
|
||||
// ignored because we're running a check after this block
|
||||
}
|
||||
}
|
||||
|
||||
// fallback in case we didn't find any specified resolution
|
||||
if(!resFound) resolution = ProfileImage.parseResolution(512);
|
||||
if (!resFound) resolution = ProfileImage.parseResolution(512);
|
||||
|
||||
// check if someone is mentioned
|
||||
Mentions mentions = event.getMessage().getMentions();
|
||||
if(mentions.getMentions().isEmpty())
|
||||
if (mentions.getMentions().isEmpty())
|
||||
{
|
||||
user = event.getAuthor();
|
||||
} else
|
||||
@@ -89,14 +98,14 @@ public class AvatarCommand implements MessageCommand
|
||||
}
|
||||
|
||||
// in case of issues, fallback to the sender
|
||||
if(user == null) user = event.getAuthor();
|
||||
if (user == null) user = event.getAuthor();
|
||||
|
||||
// send a response
|
||||
MessageResponse response = ProfileImage.buildResponse(resolution, user, ProfileImage.ImageType.AVATAR);
|
||||
if(response.content() != null)
|
||||
if (response.content() != null)
|
||||
{
|
||||
event.getMessage().reply(response.content()).queue();
|
||||
} else if(response.embed() != null)
|
||||
} else if (response.embed() != null)
|
||||
{
|
||||
event.getMessage().replyEmbeds(response.embed()).queue();
|
||||
}
|
||||
|
||||
@@ -17,36 +17,42 @@ public class BanCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Collections.singletonList("ban"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return new ArrayList<Permission>(Collections.singletonList(Permission.BAN_MEMBERS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.MODERATION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Ban the mentioned user.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "<mentioned user> [reason]";
|
||||
}
|
||||
|
||||
|
||||
@@ -20,36 +20,42 @@ public class BannerCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Collections.singletonList("banner"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null; // anyone can use it
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Get someone's profile banner, or your own.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "[mentioned user] [resolution]";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.TOOLS;
|
||||
}
|
||||
|
||||
@@ -63,23 +69,26 @@ public class BannerCommand implements MessageCommand
|
||||
// (mentions are handled differently by a specific method)
|
||||
boolean resFound = false;
|
||||
|
||||
for (String arg : args) {
|
||||
try {
|
||||
for (String arg : args)
|
||||
{
|
||||
try
|
||||
{
|
||||
int givenRes = Integer.parseInt(arg);
|
||||
resolution = ProfileImage.parseResolution(givenRes);
|
||||
resFound = true;
|
||||
break;
|
||||
} catch (NumberFormatException ignored) {
|
||||
} catch (NumberFormatException ignored)
|
||||
{
|
||||
// ignored because we're running a check after this block
|
||||
}
|
||||
}
|
||||
|
||||
// fallback in case we didn't find any specified resolution
|
||||
if(!resFound) resolution = ProfileImage.parseResolution(512);
|
||||
if (!resFound) resolution = ProfileImage.parseResolution(512);
|
||||
|
||||
// check if someone is mentioned
|
||||
Mentions mentions = event.getMessage().getMentions();
|
||||
if(mentions.getMentions().isEmpty())
|
||||
if (mentions.getMentions().isEmpty())
|
||||
{
|
||||
user = event.getAuthor();
|
||||
} else
|
||||
@@ -89,14 +98,14 @@ public class BannerCommand implements MessageCommand
|
||||
}
|
||||
|
||||
// in case of issues, fallback to the sender
|
||||
if(user == null) user = event.getAuthor();
|
||||
if (user == null) user = event.getAuthor();
|
||||
|
||||
// send a response
|
||||
MessageResponse response = ProfileImage.buildResponse(resolution, user, ProfileImage.ImageType.BANNER);
|
||||
if(response.content() != null)
|
||||
if (response.content() != null)
|
||||
{
|
||||
event.getMessage().reply(response.content()).queue();
|
||||
} else if(response.embed() != null)
|
||||
} else if (response.embed() != null)
|
||||
{
|
||||
event.getMessage().replyEmbeds(response.embed()).queue();
|
||||
}
|
||||
|
||||
@@ -18,46 +18,54 @@ public class BotInfoCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Arrays.asList("botinfo", "info"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null; // anyone can use it
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Get general info about the bot.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.TOOLS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(MessageReceivedEvent event, String label, String[] args) {
|
||||
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||
{
|
||||
|
||||
// get a list of message commands
|
||||
LinkedList<MessageCommand> messageCommands = Cache.getMessageCommandListener().getRegisteredCommands();
|
||||
LinkedList<String> commandNames = new LinkedList<>();
|
||||
for (MessageCommand command : messageCommands) {
|
||||
for (MessageCommand command : messageCommands)
|
||||
{
|
||||
commandNames.add(command.getCommandLabels().get(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,33 +19,41 @@ public class ClearCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Collections.singletonList(ClearChat.getLabel()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Permission> getPermissions() { return Collections.singletonList(ClearChat.getPermission()); }
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return Collections.singletonList(ClearChat.getPermission());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.MODERATION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Clear the current channel's chat history.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "[amount]";
|
||||
}
|
||||
|
||||
@@ -54,7 +62,8 @@ public class ClearCommand implements MessageCommand
|
||||
{
|
||||
// check if user is trying to run command in dms.
|
||||
String error = ClearChat.checkDMs(event.getChannel());
|
||||
if (error != null) {
|
||||
if (error != null)
|
||||
{
|
||||
event.getMessage().reply(error).queue();
|
||||
return;
|
||||
}
|
||||
@@ -64,7 +73,8 @@ public class ClearCommand implements MessageCommand
|
||||
if (args.length == 0) toDeleteAmount = 1;
|
||||
else
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
toDeleteAmount = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException e)
|
||||
{
|
||||
@@ -73,10 +83,11 @@ public class ClearCommand implements MessageCommand
|
||||
}
|
||||
|
||||
// cap the amount to avoid abuse.
|
||||
if(toDeleteAmount > ClearChat.getMaxAmount()) toDeleteAmount = 0;
|
||||
if (toDeleteAmount > ClearChat.getMaxAmount()) toDeleteAmount = 0;
|
||||
|
||||
error = ClearChat.checkDeleteAmount(toDeleteAmount);
|
||||
if (error != null) {
|
||||
if (error != null)
|
||||
{
|
||||
event.getMessage().reply(error).queue();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,41 +16,48 @@ public class CoinFlipCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Arrays.asList("coinflip", "flip", "flipcoin"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null; // null because it can be used anywhere
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Flip a coin.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.FUN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(MessageReceivedEvent event, String label, String[] args) {
|
||||
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||
{
|
||||
|
||||
// perform coin flip
|
||||
event.getMessage().reply(CoinFlip.genRandom())
|
||||
@@ -59,6 +66,7 @@ public class CoinFlipCommand implements MessageCommand
|
||||
{
|
||||
// set the command as expiring and restrict it to the user who ran it
|
||||
CoinFlip.trackAndRestrict(message, event.getAuthor());
|
||||
}, (error) -> {});
|
||||
}, (error) -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,18 +16,21 @@ import java.util.List;
|
||||
public class DiceRollCommand implements MessageCommand
|
||||
{
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Arrays.asList("diceroll", "droll", "roll"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null; // anyone can use it
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,13 +50,15 @@ public class DiceRollCommand implements MessageCommand
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "[dice size] [rolls]";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.FUN;
|
||||
}
|
||||
|
||||
@@ -63,10 +68,10 @@ public class DiceRollCommand implements MessageCommand
|
||||
|
||||
MessageResponse response = DiceRoll.buildResponse(event.getAuthor(), args);
|
||||
|
||||
if(response.content() != null)
|
||||
if (response.content() != null)
|
||||
{
|
||||
event.getMessage().reply(response.content()).queue();
|
||||
} else if(response.embed() != null)
|
||||
} else if (response.embed() != null)
|
||||
{
|
||||
event.getMessage().replyEmbeds(response.embed()).queue();
|
||||
}
|
||||
|
||||
@@ -15,33 +15,41 @@ public class HelloCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Arrays.asList("hi", "hello", "heya"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Permission> getPermissions() { return null; }
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Get pinged by the bot.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.FUN;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,34 +18,42 @@ public class HelpCommand implements MessageCommand
|
||||
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Collections.singletonList("help"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() { return null; }
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Get general help on the bot. Specify a command if you want specific help about that command.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "[command]";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.TOOLS;
|
||||
}
|
||||
|
||||
@@ -54,14 +62,14 @@ public class HelpCommand implements MessageCommand
|
||||
{
|
||||
LinkedHashMap<CommandCategory, LinkedList<MessageCommand>> commandCategories = new LinkedHashMap<>();
|
||||
|
||||
if(args.length == 0)
|
||||
if (args.length == 0)
|
||||
{
|
||||
for(CommandCategory category : CommandCategory.values())
|
||||
for (CommandCategory category : CommandCategory.values())
|
||||
{
|
||||
LinkedList<MessageCommand> commandsOfThisCategory = new LinkedList<>();
|
||||
for (MessageCommand command : Cache.getMessageCommandListener().getRegisteredCommands())
|
||||
{
|
||||
if(command.getCategory().equals(category))
|
||||
if (command.getCategory().equals(category))
|
||||
{
|
||||
commandsOfThisCategory.add(command);
|
||||
}
|
||||
@@ -79,18 +87,18 @@ public class HelpCommand implements MessageCommand
|
||||
"\nYou will find a list of commands organized in categories below.",
|
||||
false);
|
||||
|
||||
for(Map.Entry<CommandCategory, LinkedList<MessageCommand>> entry : commandCategories.entrySet())
|
||||
for (Map.Entry<CommandCategory, LinkedList<MessageCommand>> entry : commandCategories.entrySet())
|
||||
{
|
||||
StringBuilder commandsList = new StringBuilder();
|
||||
CommandCategory category = entry.getKey();
|
||||
LinkedList<MessageCommand> commandsOfThisCategory = entry.getValue();
|
||||
|
||||
for(int pos = 0; pos < commandsOfThisCategory.size(); pos++)
|
||||
for (int pos = 0; pos < commandsOfThisCategory.size(); pos++)
|
||||
{
|
||||
MessageCommand command = commandsOfThisCategory.get(pos);
|
||||
commandsList.append("`").append(command.getCommandLabels().get(0)).append("`");
|
||||
|
||||
if(pos + 1 != commandsOfThisCategory.size())
|
||||
if (pos + 1 != commandsOfThisCategory.size())
|
||||
commandsList.append(", "); // separate with comma except on last run
|
||||
}
|
||||
|
||||
@@ -102,11 +110,12 @@ public class HelpCommand implements MessageCommand
|
||||
}
|
||||
|
||||
event.getMessage().replyEmbeds(embedBuilder.build()).queue();
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
|
||||
String commandLabel = args[0].toLowerCase();
|
||||
MessageCommand command = Cache.getMessageCommandListener().getRegisteredCommand(commandLabel);
|
||||
if(command == null)
|
||||
if (command == null)
|
||||
{
|
||||
event.getMessage().reply("Unrecognized command: `" + commandLabel + "`!").queue(); // todo prettier
|
||||
return;
|
||||
@@ -115,23 +124,24 @@ public class HelpCommand implements MessageCommand
|
||||
commandLabel = command.getCommandLabels().get(0);
|
||||
String usage = "`" + Cache.getBotPrefix() + " " + commandLabel;
|
||||
String internalUsage = command.getUsage();
|
||||
if(internalUsage != null) usage += " " + internalUsage;
|
||||
if (internalUsage != null) usage += " " + internalUsage;
|
||||
usage += "`";
|
||||
|
||||
String aliases = Alias.generateNiceAliases(command);
|
||||
|
||||
List<Permission> permissions = command.getPermissions();
|
||||
StringBuilder permissionsStringBuilder = new StringBuilder();
|
||||
if(permissions == null)
|
||||
if (permissions == null)
|
||||
{
|
||||
permissionsStringBuilder = new StringBuilder("Available to everyone");
|
||||
} else {
|
||||
for(int i = 0; i < permissions.size(); i++)
|
||||
} else
|
||||
{
|
||||
for (int i = 0; i < permissions.size(); i++)
|
||||
{
|
||||
Permission permission = permissions.get(i);
|
||||
permissionsStringBuilder.append("**").append(permission.getName()).append("**");
|
||||
|
||||
if(i + 1 != permissions.size())
|
||||
if (i + 1 != permissions.size())
|
||||
permissionsStringBuilder.append(", "); // separate with comma expect on last iteration
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,36 +19,42 @@ public class InviteCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Collections.singletonList("invite"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Get the bot's invite link.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.MODERATION;
|
||||
}
|
||||
|
||||
@@ -61,7 +67,7 @@ public class InviteCommand implements MessageCommand
|
||||
Button inviteButton = Invite.getInviteButton();
|
||||
|
||||
// if this is a guild, don't spam the invite in public but DM it
|
||||
if(event.getChannelType().isGuild())
|
||||
if (event.getChannelType().isGuild())
|
||||
{
|
||||
event.getAuthor().openPrivateChannel().queue(privateChannel ->
|
||||
{
|
||||
@@ -70,7 +76,8 @@ public class InviteCommand implements MessageCommand
|
||||
.queue();
|
||||
event.getMessage().addReaction(Emoji.fromUnicode("✅")).queue();
|
||||
}, error -> event.getMessage().addReaction(Emoji.fromUnicode("❌")).queue());
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
event.getMessage()
|
||||
.replyEmbeds(inviteEmbed)
|
||||
.addActionRow(inviteButton)
|
||||
|
||||
@@ -17,36 +17,42 @@ public class KickCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Collections.singletonList("kick"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return new ArrayList<Permission>(Collections.singletonList(Permission.KICK_MEMBERS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.MODERATION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Kick the mentioned user from the guild.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "<mentioned user> [reason]";
|
||||
}
|
||||
|
||||
|
||||
@@ -29,30 +29,35 @@ public class LoveCalculatorCommand implements MessageCommand
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null; //anyone can use it
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Calculate how much two people love each other. You can mention two people or just one.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "<person 1> [person 2]";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.FUN;
|
||||
}
|
||||
|
||||
@@ -64,7 +69,7 @@ public class LoveCalculatorCommand implements MessageCommand
|
||||
List<IMentionable> mentions = mentionsObj.getMentions();
|
||||
|
||||
|
||||
if(args.length == 0 || mentions.isEmpty())
|
||||
if (args.length == 0 || mentions.isEmpty())
|
||||
{
|
||||
event.getMessage()
|
||||
.reply("\uD83D\uDE22 I need to know who to check! Please mention them.")
|
||||
@@ -77,10 +82,11 @@ public class LoveCalculatorCommand implements MessageCommand
|
||||
String mentionedUserId = mentions.get(0).getId();
|
||||
user1 = HidekoBot.getAPI().retrieveUserById(mentionedUserId).complete();
|
||||
|
||||
if(mentions.size() == 1)
|
||||
if (mentions.size() == 1)
|
||||
{
|
||||
user2 = event.getAuthor();
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
mentionedUserId = mentions.get(1).getId();
|
||||
user2 = HidekoBot.getAPI().retrieveUserById(mentionedUserId).complete();
|
||||
}
|
||||
|
||||
@@ -15,58 +15,64 @@ public class MagicBallCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return MagicBall.getLabels();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null; // anyone can use it
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Ask a question to the Magic Ball.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "<question>";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.FUN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||
{
|
||||
if(args.length == 0)
|
||||
if (args.length == 0)
|
||||
{
|
||||
event.getMessage().reply("You need to specify a question!").queue();
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder questionBuilder = new StringBuilder();
|
||||
for(int i = 0; i < args.length; i++)
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
String arg = args[i];
|
||||
questionBuilder.append(arg);
|
||||
if(i + 1 != args.length) // don't add a separator on the last iteration
|
||||
if (i + 1 != args.length) // don't add a separator on the last iteration
|
||||
questionBuilder.append(" ");
|
||||
}
|
||||
|
||||
String question = questionBuilder.toString();
|
||||
String question = questionBuilder.toString();
|
||||
|
||||
|
||||
event.getChannel().sendMessageEmbeds(MagicBall.generateEmbed(question, event.getAuthor())).queue();
|
||||
|
||||
@@ -18,34 +18,42 @@ public class SayCommand implements MessageCommand
|
||||
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Collections.singletonList("say"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() { return Collections.singletonList(Say.getPermission()); }
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return Collections.singletonList(Say.getPermission());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Make the bot say something for you.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "<text>";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.TOOLS;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,36 +17,42 @@ public class TimeoutCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Collections.singletonList("timeout"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return new ArrayList<Permission>(Collections.singletonList(Permission.MODERATE_MEMBERS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.MODERATION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Timeout the mentioned user.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "<mentioned user> <duration> [reason]";
|
||||
}
|
||||
|
||||
|
||||
@@ -23,36 +23,42 @@ public class TriviaCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return new LinkedList<>(Collections.singletonList("trivia"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.FUN;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Start a Trivia session and play with others!";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -61,13 +67,13 @@ public class TriviaCommand implements MessageCommand
|
||||
{
|
||||
MessageChannel channel = event.getChannel();
|
||||
|
||||
if(!(channel instanceof TextChannel))
|
||||
if (!(channel instanceof TextChannel))
|
||||
{
|
||||
channel.sendMessage(Trivia.getNoDMsError()).queue();
|
||||
return;
|
||||
}
|
||||
|
||||
if(Trivia.channelsRunningTrivia.contains(channel.getId()))
|
||||
if (Trivia.channelsRunningTrivia.contains(channel.getId()))
|
||||
{
|
||||
// todo: also what if the bot stops (database...?)
|
||||
// todo: also what if the message is already deleted
|
||||
@@ -80,11 +86,12 @@ public class TriviaCommand implements MessageCommand
|
||||
|
||||
Message recvMessage = event.getMessage();
|
||||
MessageCreateAction responseAction = null;
|
||||
if(response.content() != null) responseAction = recvMessage.reply(response.content());
|
||||
else if(response.embed() != null) responseAction = recvMessage.replyEmbeds(response.embed());
|
||||
if (response.content() != null) responseAction = recvMessage.reply(response.content());
|
||||
else if (response.embed() != null) responseAction = recvMessage.replyEmbeds(response.embed());
|
||||
|
||||
if(responseAction != null) {
|
||||
if(response.components() != null) responseAction = responseAction.addActionRow(response.components());
|
||||
if (responseAction != null)
|
||||
{
|
||||
if (response.components() != null) responseAction = responseAction.addActionRow(response.components());
|
||||
|
||||
responseAction.queue(message -> {
|
||||
Cache.getDatabaseSource().trackRanCommandReply(message, event.getAuthor());
|
||||
|
||||
@@ -21,36 +21,42 @@ public class UrbanDictionaryCommand implements MessageCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommandLabels() {
|
||||
public LinkedList<String> getCommandLabels()
|
||||
{
|
||||
return UrbanDictionary.getCommandLabels();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> getPermissions() {
|
||||
public List<Permission> getPermissions()
|
||||
{
|
||||
return null; //anyone can use it
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passRawArgs() {
|
||||
public boolean passRawArgs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public String getDescription()
|
||||
{
|
||||
return "Look something up in the Urban Dictionary.";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUsage() {
|
||||
public String getUsage()
|
||||
{
|
||||
return "<query>";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory()
|
||||
{
|
||||
return CommandCategory.FUN;
|
||||
}
|
||||
|
||||
@@ -58,7 +64,7 @@ public class UrbanDictionaryCommand implements MessageCommand
|
||||
@Override
|
||||
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||
{
|
||||
if(args.length == 0)
|
||||
if (args.length == 0)
|
||||
{
|
||||
event.getMessage().reply(UrbanDictionary.getNoArgsError()).queue();
|
||||
return;
|
||||
@@ -66,11 +72,12 @@ public class UrbanDictionaryCommand implements MessageCommand
|
||||
|
||||
// sanitize args by only keeping letters and numbers, and adding "+" instead of spaces for HTML parsing
|
||||
StringBuilder termBuilder = new StringBuilder();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
String arg = args[i];
|
||||
termBuilder.append(arg);
|
||||
|
||||
if(i + 1 != args.length) // add spaces between args, but not on the last run
|
||||
if (i + 1 != args.length) // add spaces between args, but not on the last run
|
||||
termBuilder.append(" ");
|
||||
}
|
||||
|
||||
@@ -79,9 +86,11 @@ public class UrbanDictionaryCommand implements MessageCommand
|
||||
|
||||
Document doc;
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
doc = Jsoup.connect(url).get();
|
||||
} catch (IOException e) {
|
||||
} catch (IOException e)
|
||||
{
|
||||
event.getMessage().reply(UrbanDictionary.getTermNotFoundError()).queue();
|
||||
return;
|
||||
}
|
||||
@@ -92,7 +101,7 @@ public class UrbanDictionaryCommand implements MessageCommand
|
||||
|
||||
// disable next page if we only have one result
|
||||
Button nextPageBtnLocal = UrbanDictionary.getNextPageButton();
|
||||
if(search.getPages() == 1) nextPageBtnLocal = nextPageBtnLocal.asDisabled();
|
||||
if (search.getPages() == 1) nextPageBtnLocal = nextPageBtnLocal.asDisabled();
|
||||
|
||||
event.getChannel()
|
||||
.sendMessageEmbeds(embed)
|
||||
|
||||
Reference in New Issue
Block a user