package net.nevet5.buzzbot.commands; import net.nevet5.buzzbot.commands.utils.CommandContext; import net.nevet5.buzzbot.commands.utils.ICommand; import java.util.List; public class BanCmd implements ICommand { @Override public void handle(CommandContext ctx) { //TODO Add checks for commands so they dont break the bot //TODO Get username and discriminator of person banned and mod //TODO DM Person who was banned with info about ban //TODO Make bans able to be modified by original banner only String userName; long userId; long banLength; String banReason; List args = ctx.getArgs(); if (args.size() < 3) { ctx.getChannel().sendMessage("Not enough arguments, please try again").queue(); return; } if (args.get(0).contains("<@")) { userId = Long.parseLong(args.get(0).replace("<","").replace("@","").replace("&","").replace(">","")); } else { userId = Long.parseLong(args.get(0)); } if (args.get(1).contains("perm")) { banLength = 0; } else if (args.get(1).contains("h")) { banLength = Long.parseLong(args.get(1).replace("h","")); } else if (args.get(1).contains("d")) { banLength = Long.parseLong(args.get(1).replace("d","")) * 24; } else if (args.get(1).contains("w")) { banLength = Long.parseLong(args.get(1).replace("w","")) * 24 * 7; } else if (args.get(1).contains("m")) { banLength = Long.parseLong(args.get(1).replace("m", "")) * 24 * 30; } else if (args.get(1).contains("y")) { banLength = Long.parseLong(args.get(1).replace("y","")) * 24 * 365; } else { return; } StringBuilder sb = new StringBuilder(); if (args.size() >= 2) { for (int i = 2; i < args.size(); i++) { sb.append(args.get(i)); sb.append(" "); } } banReason = sb.toString().trim(); if (banLength == 0) { ctx.getChannel().sendMessage("<@" + ctx.getMessage().getAuthor().getId() + "> permanently banned <@" + userId + ">. Reason: " + banReason).queue(); } else { ctx.getChannel().sendMessage("<@" + ctx.getMessage().getAuthor().getId() + "> banned <@" + userId + "> for " + banLength + " hours. Reason: " + banReason).queue(); } //ctx.getEvent().getGuild().ban(cmdf, 1 , "").submit(); //ctx.getMessage().reply("yes ban"); } @Override public String getName() { return "ban"; } @Override public String getHelp() { return "Bans the specified user"; } }