use of net.dv8tion.jda.core.entities.Role in project TheLighterBot by PhotonBursted.
the class AccesslistModificationCommand method performAccesslistModification.
private void performAccesslistModification(BannableEntity target) {
if (performActionCheck(ev.getGuild(), target)) {
if (target.isOfClass(User.class)) {
User targetUser = (User) target.get();
if (targetUser.equals(l.getBot().getSelfUser())) {
handleError("Access list operations cannot be executed on the bot itself!");
return;
}
handleError(String.format("User **%s** is already %s for this server!", Utils.userAsString((User) target.get()), getActionDescription("%sed", "not present in the %s")));
return;
}
if (target.isOfClass(Role.class)) {
handleError(String.format("Role **%s** is already %s for this server!", ((Role) target.get()).getName(), getActionDescription("%sed", "not present in the %s")));
return;
}
handleError(String.format("This entity is already %s for this server!", getActionDescription("%sed", "not present in the %s")));
return;
}
String response = performAction(ev.getGuild(), target);
LoggerUtils.logAndDelete(log, response);
l.getDiscordController().sendMessage(ev, String.format("%s **%s** was successfully %s!", StringUtils.capitalize(target.get().getClass().getSimpleName().toLowerCase().replace("impl", "")), target.isOfClass(User.class) ? Utils.userAsString((User) target.get()) : target.isOfClass(Role.class) ? String.format("`%s`", ((Role) target.get()).getName()) : "", getActionDescription("%sed", "removed from the %s")), DiscordController.AUTOMATIC_REMOVAL_INTERVAL);
}
Aggregations