Advertisement
Vaerys_Dawn

Old vs new Help command

Aug 16th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.19 KB | None | 0 0
  1.     @Override
  2.     public String execute(String args, CommandObject command) {
  3.         XEmbedBuilder helpEmbed = new XEmbedBuilder();
  4.         List<String> types = new ArrayList<>(command.guild.getAllTypes(command));
  5.         List<Command> commands = new ArrayList<>(command.guild.getAllCommands(command));
  6.         String error = "> There are no commands with the type: **" + args + "**.\n\n" + Utility.getCommandInfo(this, command);
  7.         helpEmbed.withColor(command.client.color);
  8.         ListIterator iterator = types.listIterator();
  9.         while (iterator.hasNext()) {
  10.             String s = (String) iterator.next();
  11.             if (Utility.getCommandsByType(commands, command, s, true).size() == 0) {
  12.                 iterator.remove();
  13.             }
  14.         }
  15.         Collections.sort(types);
  16.         if (args == null || args.isEmpty()) {
  17.             StringBuilder builder = new StringBuilder();
  18.             builder.append(codeBlock + "\n");
  19.             builder.append(Utility.listFormatter(types, false));
  20.             builder.append(codeBlock + "\n");
  21.             helpEmbed.withTitle("Here are the Command Types I have available for use:");
  22.             builder.append(Utility.getCommandInfo(this, command) + "\n");
  23.             helpEmbed.withDescription(builder.toString());
  24.             Utility.sendEmbedMessage("", helpEmbed, command.channel.get());
  25.             return null;
  26.         } else {
  27.             for (String s : types) {
  28.                 if (s.equalsIgnoreCase(args)) {
  29.                     StringBuilder builder = new StringBuilder();
  30.                     String suffix = Utility.getCommandInfo(new Info(), command);
  31.                     helpEmbed.withTitle("> Here are all of the " + s + " Commands I have available.");
  32.                     if (args.equalsIgnoreCase(TYPE_DM)) {
  33.                         suffix = "**These commands can only be performed in DMs.**\n" +
  34.                                 "> If you send a non command message to my DMs it will send it to my creator.\n\n" + suffix;
  35.                     } else if (args.equalsIgnoreCase(TYPE_CREATOR)) {
  36.                         suffix = "**Only the creator of this bot can run these commands.**\n\n" + suffix;
  37.                     }
  38.                     builder.append(codeBlock + "\n");
  39.                     List<String> commandNames = new ArrayList<>();
  40.                     for (Command c : Utility.getCommandsByType(commands, command, s, true)) {
  41.                         StringBuilder commandCall = new StringBuilder(c.getCommand(command));
  42.                         if (c.dualType() != null) {
  43.                             commandCall.append(indent + "*");
  44.                         }
  45.                         commandNames.add(commandCall.toString());
  46.                     }
  47.                     builder.append(Utility.listFormatter(commandNames, false));
  48.                     builder.append(codeBlock + "\n");
  49.                     builder.append(suffix);
  50.                     helpEmbed.withDescription(builder.toString());
  51.                     Utility.sendEmbedMessage("", helpEmbed, command.channel.get());
  52.                     return null;
  53.                 }
  54.             }
  55.             return error;
  56.         }
  57.  
  58.  
  59. //        ArrayList<String> types = new ArrayList<>(command.guild.commandTypes);
  60. //        StringBuilder builder = new StringBuilder();
  61. //        ArrayList<String> commandList = new ArrayList<>();
  62. //        String error = "> There are no commands with the type: **" + args + "**.\n" + Utility.getCommandInfo(this, command);
  63. //        //setting embed colour to match Bot's Colour
  64. //        Color color = Utility.getUsersColour(Globals.getClient().getOurUser(), command.guild.get());
  65. //        if (color != null) {
  66. //            helpEmbed.withColor(color);
  67. //        }
  68. //
  69. //        //getting Types of com.github.vaerys.commands.
  70. //
  71. //        if (!command.user.stringID.equalsIgnoreCase(Globals.creatorID)) {
  72. //            for (int i = 0; i < types.size(); i++) {
  73. //                if (types.get(i).equals(TYPE_CREATOR)) {
  74. //                    types.remove(i);
  75. //                }
  76. //            }
  77. //        }
  78. //
  79. //        //sort types
  80. //        Collections.sort(types);
  81. //
  82. //        boolean showAdmin = false;
  83. //        for (Command c : command.guild.commands) {
  84. //            if (c.type().equals(Command.TYPE_ADMIN)) {
  85. //                if (Utility.testForPerms(c.perms(), command.user.get(), command.guild.get())) {
  86. //                    showAdmin = true;
  87. //                }
  88. //            }
  89. //        }
  90. //
  91. //        if (!showAdmin) {
  92. //            for (int i = 0; i < types.size(); i++) {
  93. //                if (types.get(i).equalsIgnoreCase(Command.TYPE_ADMIN)) {
  94. //                    types.remove(i);
  95. //                }
  96. //            }
  97. //        }
  98. //
  99. //        //building the embed
  100. //        if (args.isEmpty()) {
  101. //            builder.append(codeBlock + "\n");
  102. //            builder.append(Utility.listFormatter(types, false));
  103. //            builder.append(codeBlock + "\n");
  104. //            helpEmbed.withTitle("Here are the Command Types I have available for use:");
  105. //            builder.append(Utility.getCommandInfo(this, command) + "\n");
  106. //            helpEmbed.withDescription(builder.toString());
  107. ////            helpEmbed.appendField("Helpful Links", desc, true);
  108. //
  109. //        } else {
  110. //            boolean isFound = false;
  111. //            String title = "ERROR";
  112. //            String suffix = Utility.getCommandInfo(new Info(), command);
  113. //            for (String s : types) {
  114. //                if (args.equalsIgnoreCase(s) || args.equalsIgnoreCase(command.guild.config.getPrefixCommand() + s)) {
  115. //                    title = "> Here are all of the " + s + " Commands I have available.";
  116. //                    isFound = true;
  117. //                    if (s.equalsIgnoreCase(TYPE_DM)) {
  118. //                        for (Command cDM : Globals.getCommandsDM()) {
  119. //                            if (!cDM.type().equalsIgnoreCase(DMCommand.TYPE_CREATOR)) {
  120. //                                commandList.add(Globals.defaultPrefixCommand + cDM.names()[0]);
  121. //                            }
  122. //                        }
  123. //                        suffix =
  124. //                    } else {
  125. //                        for (Command c : command.guild.commands) {
  126. //                            if (Utility.testForPerms(c.perms(), command.user.get(), command.guild.get())) {
  127. //                                if (c.type().equalsIgnoreCase(s)) {
  128. //                                    if (c.dualType() != null) {
  129. //                                        commandList.add(c.getCommand(command) + indent + "*");
  130. //                                    } else {
  131. //                                        commandList.add(c.getCommand(command));
  132. //                                    }
  133. //                                }
  134. //                            }
  135. //                        }
  136. //                    }
  137. //                }
  138. //            }
  139. //            Collections.sort(commandList);
  140. //            Utility.listFormatterEmbed(title, helpEmbed, commandList, false, suffix);
  141. //            if (!isFound) {
  142. //                return error;
  143. //            }
  144. //        }
  145. //        Utility.sendEmbedMessage("", helpEmbed, command.channel.get());
  146. //        return null;
  147.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement