Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public String execute(String args, CommandObject command) {
- XEmbedBuilder helpEmbed = new XEmbedBuilder();
- List<String> types = new ArrayList<>(command.guild.getAllTypes(command));
- List<Command> commands = new ArrayList<>(command.guild.getAllCommands(command));
- String error = "> There are no commands with the type: **" + args + "**.\n\n" + Utility.getCommandInfo(this, command);
- helpEmbed.withColor(command.client.color);
- ListIterator iterator = types.listIterator();
- while (iterator.hasNext()) {
- String s = (String) iterator.next();
- if (Utility.getCommandsByType(commands, command, s, true).size() == 0) {
- iterator.remove();
- }
- }
- Collections.sort(types);
- if (args == null || args.isEmpty()) {
- StringBuilder builder = new StringBuilder();
- builder.append(codeBlock + "\n");
- builder.append(Utility.listFormatter(types, false));
- builder.append(codeBlock + "\n");
- helpEmbed.withTitle("Here are the Command Types I have available for use:");
- builder.append(Utility.getCommandInfo(this, command) + "\n");
- helpEmbed.withDescription(builder.toString());
- Utility.sendEmbedMessage("", helpEmbed, command.channel.get());
- return null;
- } else {
- for (String s : types) {
- if (s.equalsIgnoreCase(args)) {
- StringBuilder builder = new StringBuilder();
- String suffix = Utility.getCommandInfo(new Info(), command);
- helpEmbed.withTitle("> Here are all of the " + s + " Commands I have available.");
- if (args.equalsIgnoreCase(TYPE_DM)) {
- suffix = "**These commands can only be performed in DMs.**\n" +
- "> If you send a non command message to my DMs it will send it to my creator.\n\n" + suffix;
- } else if (args.equalsIgnoreCase(TYPE_CREATOR)) {
- suffix = "**Only the creator of this bot can run these commands.**\n\n" + suffix;
- }
- builder.append(codeBlock + "\n");
- List<String> commandNames = new ArrayList<>();
- for (Command c : Utility.getCommandsByType(commands, command, s, true)) {
- StringBuilder commandCall = new StringBuilder(c.getCommand(command));
- if (c.dualType() != null) {
- commandCall.append(indent + "*");
- }
- commandNames.add(commandCall.toString());
- }
- builder.append(Utility.listFormatter(commandNames, false));
- builder.append(codeBlock + "\n");
- builder.append(suffix);
- helpEmbed.withDescription(builder.toString());
- Utility.sendEmbedMessage("", helpEmbed, command.channel.get());
- return null;
- }
- }
- return error;
- }
- // ArrayList<String> types = new ArrayList<>(command.guild.commandTypes);
- // StringBuilder builder = new StringBuilder();
- // ArrayList<String> commandList = new ArrayList<>();
- // String error = "> There are no commands with the type: **" + args + "**.\n" + Utility.getCommandInfo(this, command);
- // //setting embed colour to match Bot's Colour
- // Color color = Utility.getUsersColour(Globals.getClient().getOurUser(), command.guild.get());
- // if (color != null) {
- // helpEmbed.withColor(color);
- // }
- //
- // //getting Types of com.github.vaerys.commands.
- //
- // if (!command.user.stringID.equalsIgnoreCase(Globals.creatorID)) {
- // for (int i = 0; i < types.size(); i++) {
- // if (types.get(i).equals(TYPE_CREATOR)) {
- // types.remove(i);
- // }
- // }
- // }
- //
- // //sort types
- // Collections.sort(types);
- //
- // boolean showAdmin = false;
- // for (Command c : command.guild.commands) {
- // if (c.type().equals(Command.TYPE_ADMIN)) {
- // if (Utility.testForPerms(c.perms(), command.user.get(), command.guild.get())) {
- // showAdmin = true;
- // }
- // }
- // }
- //
- // if (!showAdmin) {
- // for (int i = 0; i < types.size(); i++) {
- // if (types.get(i).equalsIgnoreCase(Command.TYPE_ADMIN)) {
- // types.remove(i);
- // }
- // }
- // }
- //
- // //building the embed
- // if (args.isEmpty()) {
- // builder.append(codeBlock + "\n");
- // builder.append(Utility.listFormatter(types, false));
- // builder.append(codeBlock + "\n");
- // helpEmbed.withTitle("Here are the Command Types I have available for use:");
- // builder.append(Utility.getCommandInfo(this, command) + "\n");
- // helpEmbed.withDescription(builder.toString());
- //// helpEmbed.appendField("Helpful Links", desc, true);
- //
- // } else {
- // boolean isFound = false;
- // String title = "ERROR";
- // String suffix = Utility.getCommandInfo(new Info(), command);
- // for (String s : types) {
- // if (args.equalsIgnoreCase(s) || args.equalsIgnoreCase(command.guild.config.getPrefixCommand() + s)) {
- // title = "> Here are all of the " + s + " Commands I have available.";
- // isFound = true;
- // if (s.equalsIgnoreCase(TYPE_DM)) {
- // for (Command cDM : Globals.getCommandsDM()) {
- // if (!cDM.type().equalsIgnoreCase(DMCommand.TYPE_CREATOR)) {
- // commandList.add(Globals.defaultPrefixCommand + cDM.names()[0]);
- // }
- // }
- // suffix =
- // } else {
- // for (Command c : command.guild.commands) {
- // if (Utility.testForPerms(c.perms(), command.user.get(), command.guild.get())) {
- // if (c.type().equalsIgnoreCase(s)) {
- // if (c.dualType() != null) {
- // commandList.add(c.getCommand(command) + indent + "*");
- // } else {
- // commandList.add(c.getCommand(command));
- // }
- // }
- // }
- // }
- // }
- // }
- // }
- // Collections.sort(commandList);
- // Utility.listFormatterEmbed(title, helpEmbed, commandList, false, suffix);
- // if (!isFound) {
- // return error;
- // }
- // }
- // Utility.sendEmbedMessage("", helpEmbed, command.channel.get());
- // return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement