Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static RequestBuffer.RequestFuture<Boolean> roleManagement(IUser author, IGuild guild, List<IRole> userRoles) {
- return RequestBuffer.request(() -> {
- try {
- IRole[] roles = new IRole[userRoles.size()];
- int i = 0;
- for (IRole r : userRoles) {
- if (r == null) {
- logger.error("ROLE RETURNED NULL");
- }
- roles[i] = r;
- i++;
- }
- guild.editUserRoles(author, roles);
- } catch (MissingPermissionsException e) {
- if (e.getMessage().contains("Edited roles hierarchy is too high.")) {
- logger.debug("Error Editing roles of user with id: " + author.getID() + " on guild with id: " + guild.getID() +
- ".\n" + Constants.PREFIX_EDT_LOGGER_INDENT + "Reason: Edited roles hierarchy is too high.");
- return true;
- } else {
- e.printStackTrace();
- return true;
- }
- } catch (DiscordException e) {
- if (e.getMessage().contains("CloudFlare")) {
- roleManagement(author, guild, userRoles);
- } else {
- e.printStackTrace();
- return true;
- }
- } catch (RuntimeException e){
- e.printStackTrace();
- }
- return false;
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment