use of stream.flarebot.flarebot.util.objects.RestActionRunnable in project FlareBot by FlareBot.
the class PruneCommand method onCommand.
@Override
public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
if (args.length != 0) {
if (args[0].equalsIgnoreCase("server") && args.length == 2) {
// Re-add sub-permission when roles is added
int amount;
try {
amount = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
MessageUtils.sendErrorMessage("Please enter a valid amount of days!", channel);
return;
}
if (amount == 0) {
MessageUtils.sendErrorMessage("The amount of days has to be more that 0!", channel);
return;
}
if (amount > 30) {
MessageUtils.sendErrorMessage("You can only prune a maximum of 30 days!", channel);
return;
}
int userSize = guild.getGuild().getPrunableMemberCount(amount).complete();
MessageUtils.sendErrorMessage(FormatUtils.formatCommandPrefix(guild, "Are you sure you want to prune " + userSize + " members?\n" + "To confirm type `{%}prune confirm` within 1 minute!"), channel);
ConfirmUtil.pushAction(sender.getId(), new RunnableWrapper(new RestActionRunnable(guild.getGuild().getController().prune(amount).reason("Pruned by user: " + MessageUtils.getTag(sender))), this.getClass()));
return;
} else if (args[0].equalsIgnoreCase("confirm")) {
if (ConfirmUtil.checkExists(sender.getId(), this.getClass())) {
ConfirmUtil.run(sender.getId(), this.getClass());
ConfirmUtil.remove(sender.getId(), this.getClass());
} else {
MessageUtils.sendErrorMessage("You haven't got any action to confirm!", channel);
}
return;
}
}
MessageUtils.sendUsage(this, channel, sender, args);
}
Aggregations