Vaerys_Dawn

RoleManagement

Mar 16th, 2017
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1.     public static RequestBuffer.RequestFuture<Boolean> roleManagement(IUser author, IGuild guild, List<IRole> userRoles) {
  2.         return RequestBuffer.request(() -> {
  3.             try {
  4.                 IRole[] roles = new IRole[userRoles.size()];
  5.                 int i = 0;
  6.                 for (IRole r : userRoles) {
  7.                     if (r == null) {
  8.                         logger.error("ROLE RETURNED NULL");
  9.                     }
  10.                     roles[i] = r;
  11.                     i++;
  12.                 }
  13.                 guild.editUserRoles(author, roles);
  14.             } catch (MissingPermissionsException e) {
  15.                 if (e.getMessage().contains("Edited roles hierarchy is too high.")) {
  16.                     logger.debug("Error Editing roles of user with id: " + author.getID() + " on guild with id: " + guild.getID() +
  17.                             ".\n" + Constants.PREFIX_EDT_LOGGER_INDENT + "Reason: Edited roles hierarchy is too high.");
  18.                     return true;
  19.                 } else {
  20.                     e.printStackTrace();
  21.                     return true;
  22.                 }
  23.             } catch (DiscordException e) {
  24.                 if (e.getMessage().contains("CloudFlare")) {
  25.                     roleManagement(author, guild, userRoles);
  26.                 } else {
  27.                     e.printStackTrace();
  28.                     return true;
  29.                 }
  30.             } catch (RuntimeException e){
  31.                 e.printStackTrace();
  32.             }
  33.             return false;
  34.         });
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment