public VoiceChannelUpdateUserLimitEvent(JDA api, long responseNumber, VoiceChannel channel, int oldUserLimit) { super(api, responseNumber, channel); this.oldUserLimit = oldUserLimit; this.newUserLimit = channel.getUserLimit(); }
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"); } } }
private VoiceConnectStatus canConnectToChannel(Message message, VoiceChannel channel) { List<Permission> permissions = message.getGuild().getMember(message.getJDA().getSelfUser()).getPermissions(channel); if (!permissions.contains(Permission.VOICE_CONNECT)) { return VoiceConnectStatus.MISSING_PERMISSIONS; } if (channel.getUserLimit() > 0 && !permissions.contains(Permission.VOICE_MOVE_OTHERS) && channel.getUserLimit() <= channel.getMembers().size()) { return VoiceConnectStatus.USER_LIMIT; } return null; }
channel.getGuild().getSelfMember() .hasPermission(member.getVoiceState().getChannel(), Permission.VOICE_SPEAK)) { if (member.getVoiceState().getChannel().getUserLimit() > 0 && member.getVoiceState().getChannel() .getMembers().size() >= member.getVoiceState().getChannel().getUserLimit() && !member.getGuild().getSelfMember() .hasPermission(member.getVoiceState().getChannel(), Permission.MANAGE_CHANNEL)) { MessageUtils.sendErrorMessage("We can't join :(\n\nThe channel user limit has been reached and we don't have the 'Manage Channel' permission to " +
&& vc.getUserLimit() != 0 && vc.getUserLimit() <= vc.getMembers().size()) { return Templates.music.join_channel_full.formatGuild(channel, vc.getName());