Example #1
0
 private void deleteCommand(UserChatEvent e, String[] args) {
   Command cmd = Command.findCommand(e.getServer().getId(), args[1]);
   if (cmd == null) {
     Utils.error(e.getGroup(), e.getUser().getUser(), " That command does not exist!");
     return;
   }
   cmd.delete();
   Utils.info(
       e.getGroup(), Main.getCommandPrefix(e.getServer().getId()) + args[1] + " was deleted!");
 }
Example #2
0
 private void addCommand(UserChatEvent e, String[] args) {
   if (Command.findCommand(e.getServer().getId(), args[1]) != null) {
     Utils.error(e.getGroup(), e.getUser().getUser(), " This command already exists!");
     return;
   }
   int delimiters = 0;
   String instructions = "", desc = "";
   for (int i = 2; i < args.length; i++)
     if (args[i].startsWith("{delimiters="))
       delimiters = Utils.stringToInt(args[i].split("\\{delimiters=")[1].split("}")[0]);
     else if (args[i].contains("{desc=")) desc = instructions.split("\\{desc=")[1].split("}")[0];
     else instructions += " " + args[i];
   instructions = instructions.substring(1);
   Command cmd = new Command(e.getServer().getId(), args[1], instructions, delimiters, desc);
   cmd.save();
   Utils.info(
       e.getGroup(), Main.getCommandPrefix(e.getServer().getId()) + args[1] + " was added!");
 }
Example #3
0
  private void setDelimiters(UserChatEvent e, String[] args) {
    Command cmd = Command.findCommand(e.getServer().getId(), args[1]);
    if (cmd == null) {
      Utils.error(e.getGroup(), e.getUser().getUser(), " This command does not exist!");
      return;
    }
    String dels = "";
    for (int i = 2; i < cmd.getDelimiterCount() + 2; i++) dels += " " + args[i];

    String instructions = "";
    for (int i = cmd.getDelimiterCount() + 2; i < args.length; i++) instructions += " " + args[i];
    cmd.setDelimiter(dels.substring(1).split(" "), instructions.substring(1));
    cmd.save();
    Utils.info(
        e.getGroup(),
        "The delimiter combination for "
            + Main.getCommandPrefix(e.getServer().getId())
            + args[1]
            + " was set!");
  }
Example #4
0
 @Override
 public void onCommand(UserChatEvent e, String[] args) {
   e.getMsg().deleteMessage();
   if (!Utils.checkArguments(e, args, 2)) return;
   switch (args[0].toLowerCase()) {
     case "add":
       addCommand(e, args);
       break;
     case "setdel":
       setDelimiters(e, args);
       break;
     case "del":
       deleteCommand(e, args);
       break;
     default:
       break;
   }
 }