private void checkChannel(VoiceChannel channel, Member self) { EnumSet<Permission> perms = Permission.toEnumSet(PermissionUtil.getEffectivePermission(channel, self)); if (!perms.contains(Permission.VOICE_CONNECT)) throw new InsufficientPermissionException(Permission.VOICE_CONNECT); final int userLimit = channel.getUserLimit(); // userLimit is 0 if no limit is set! if (userLimit > 0 && !perms.contains(Permission.ADMINISTRATOR)) { // Check if we can actually join this channel // - If there is a userlimit // - If that userlimit is reached // - If we don't have voice move others permissions // VOICE_MOVE_OTHERS allows access because you would be able to move people out to // open up a slot anyway if (userLimit <= channel.getMembers().size() && !perms.contains(Permission.VOICE_MOVE_OTHERS)) { throw new InsufficientPermissionException(Permission.VOICE_MOVE_OTHERS, "Unable to connect to VoiceChannel due to userlimit! Requires permission VOICE_MOVE_OTHERS to bypass"); } } }
for (Permission p : Permission.toEnumSet(permissions)) checkPermission(p);