/** * The {@link net.dv8tion.jda.core.entities.Guild Guild} this Manager's * {@link net.dv8tion.jda.core.entities.Role Role} is in. * <br>This is logically the same as calling {@code getRole().getGuild()} * * @return The parent {@link net.dv8tion.jda.core.entities.Guild Guild} */ public Guild getGuild() { return getRole().getGuild(); }
private void setupPermissions() { if (!shouldUpdate(PERMISSION)) this.permissions = getRole().getPermissionsRaw(); } }
@Override protected RequestBody finalizeData() { JSONObject object = new JSONObject().put("name", getRole().getName()); if (shouldUpdate(NAME)) object.put("name", name); if (shouldUpdate(PERMISSION)) object.put("permissions", permissions); if (shouldUpdate(HOIST)) object.put("hoist", hoist); if (shouldUpdate(MENTIONABLE)) object.put("mentionable", mentionable); if (shouldUpdate(COLOR)) object.put("color", color == Role.DEFAULT_COLOR_RAW ? 0 : color & 0xFFFFFF); reset(); return getRequestBody(object); }
@Override protected boolean checkPermissions() { Member selfMember = getGuild().getSelfMember(); if (!selfMember.hasPermission(Permission.MANAGE_ROLES)) throw new InsufficientPermissionException(Permission.MANAGE_ROLES); if (!selfMember.canInteract(getRole())) throw new HierarchyException("Cannot modify a role that is higher or equal in hierarchy"); return super.checkPermissions(); /* //we can't reliably check the permissions of the role here long missingRaw = permissions; missingRaw &= ~selfPermissions; // exclude own perms missingRaw &= ~role.getPermissionsRaw(); // exclude role perms if (missingRaw != 0) { List<Permission> missingPermissions = Permission.getPermissions(missingRaw); if (!missingPermissions.isEmpty()) throw new InsufficientPermissionException(missingPermissions.get(0)); } */ }