public VoiceChannelUpdateNameEvent(JDA api, long responseNumber, VoiceChannel channel, String oldName) { super(api, responseNumber, channel); this.oldName = oldName; this.newName = channel.getName(); }
/** * The {@link net.dv8tion.jda.core.entities.Guild Guild} * <br>Shortcut for {@code getChannel().getGuild()} * * @return The Guild */ public Guild getGuild() { return channel.getGuild(); } }
/** * Sets the AFK {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannel} of this {@link net.dv8tion.jda.core.entities.Guild Guild}. * * @param afkChannel * The new afk channel for this {@link net.dv8tion.jda.core.entities.Guild Guild} * or {@code null} to reset * * @throws IllegalArgumentException * If the provided channel is not from this guild * * @return GuildManager for chaining convenience */ @CheckReturnValue public GuildManager setAfkChannel(VoiceChannel afkChannel) { Checks.check(afkChannel == null || afkChannel.getGuild().equals(getGuild()), "Channel must be from the same guild"); this.afkChannel = afkChannel == null ? null : afkChannel.getId(); set |= AFK_CHANNEL; return this; }
@Override public int compareTo(VoiceChannel chan) { Checks.notNull(chan, "Other VoiceChannel"); if (this == chan) return 0; Checks.check(getGuild().equals(chan.getGuild()), "Cannot compare VoiceChannels that aren't from the same guild!"); if (this.getPositionRaw() == chan.getPositionRaw()) return Long.compare(id, chan.getIdLong()); return Integer.compare(rawPosition, chan.getPositionRaw()); }
public static String listOfVChannels(List<VoiceChannel> list, String query) { String out = " Multiple voice channels found matching \""+query+"\":"; for(int i=0; i<6 && i<list.size(); i++) out+="\n - "+list.get(i).getName()+" (ID:"+list.get(i).getId()+")"; if(list.size()>6) out+="\n**And "+(list.size()-6)+" more...**"; return out; }
context.getEvent().getTextChannel(), playerManager); if (musicManager.getState().isConnectionOpen() && musicManager.getPlayer().getPlayingTrack() != null && musicManager.getState().getVoiceChannelId().get() != channel.getIdLong() && !context.getEvent().getMember().hasPermission(context.getEvent().getJDA().getVoiceChannelById(musicManager.getState().getVoiceChannelId().get()), Permission.VOICE_MOVE_OTHERS)) { context.reply("dabBot is already playing music in %s so it cannot be moved. Members with the `Move Members` permission can do this.", context.getEvent().getJDA().getVoiceChannelById(musicManager.getState().getVoiceChannelId().get()).getName()); return;
public void setChannel(VoiceChannel channel) { this.channelId = channel.getIdLong(); }
private void handleVoiceConnectivity(VoiceChannel channel) { if (channel.getMembers().contains(channel.getGuild().getSelfMember()) && (channel.getMembers().size() < 2 || channel.getMembers() .stream().filter(m -> m.getUser().isBot()).count() == channel.getMembers().size())) { channel.getGuild().getAudioManager().closeAudioConnection(); } }
private int getAmountOfUsersConnectedToVoice(CommandMessage context) { VoiceChannel connectedChannel = LavalinkManager.LavalinkManagerHolder.lavalink.getConnectedChannel(context.getGuild()); if (connectedChannel == null) { return 0; } return connectedChannel.getMembers().stream() .filter(m -> !m.getUser().isBot()).collect(Collectors.toList()).size(); }
public void openConnection(final VoiceChannel voiceChannel, User user) { final Guild guild = voiceChannel.getGuild(); Member selfMember = guild.getSelfMember(); state.setVoiceConnectionOpen(voiceChannel.getIdLong()); } finally { lock.unlock(); "**dabBot does not have permission to connect to the %s voice channel.**\nTo fix this, " + "allow dabBot to `View Channel`, `Connect` and `Speak` in that voice channel.\nIf you " + "are not the guild owner, please send this to them.", voiceChannel.getName());
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"); } } }
"**AFK:**\n" + "Channel: " + guild.getAfkChannel().getName() + "\n" + "\n" + "Timeout: " + "\n" + "Active: " + guild.getVoiceChannels().stream().filter(voiceChannel -> voiceChannel.getMembers().size() > 0).count() + "\n" + "\n" + afk, true); eb.addField("Misc info", "**Creation time:** " +
return Templates.music.join_no_permission.formatGuild(channel, vc.getName()); && vc.getUserLimit() != 0 && vc.getUserLimit() <= vc.getMembers().size()) { return Templates.music.join_channel_full.formatGuild(channel, vc.getName());
.getId() .equals(member.getVoiceState().getChannel().getId()) && !getPermissions(channel).hasPermission(member, Permission.SKIP_FORCE)) { MessageUtils.sendAutoDeletedMessage(new MessageBuilder().append("You must be in the channel in order to skip songs!").build(), TimeUnit.SECONDS.toMillis(5), channel); channel.getGuild().getMember(sender).getVoiceState().getChannel().getIdLong() != channel.getGuild().getSelfMember().getVoiceState().getChannel().getIdLong()) { MessageUtils.sendWarningMessage("You cannot skip if you aren't listening to it!", channel); return; VoteGroup group = new VoteGroup("Skip current song", skipUUID); List<User> users = new ArrayList<>(); for (Member inChannelMember : channel.getGuild().getSelfMember().getVoiceState().getChannel().getMembers()) { if (channel.getGuild().getSelfMember().getUser().getIdLong() != inChannelMember.getUser().getIdLong()) { users.add(inChannelMember.getUser()); channel.getGuild().getMember(sender).getVoiceState().getChannel().getIdLong() != channel.getGuild().getSelfMember().getVoiceState().getChannel().getIdLong()) { MessageUtils.sendWarningMessage("You cannot vote to skip if you aren't listening to it!", channel); return;
protected void updateUserSSRC(int ssrc, long userId) { if (ssrcMap.containsKey(ssrc)) { long previousId = ssrcMap.get(ssrc); if (previousId != userId) { //Different User already existed with this ssrc. What should we do? Just replace? Probably should nuke the old opusDecoder. //Log for now and see if any user report the error. LOG.error("Yeah.. So.. JDA received a UserSSRC update for an ssrc that already had a User set. Inform DV8FromTheWorld.\nChannelId: {} SSRC: {} oldId: {} newId: {}", channel.get().getId(), ssrc, previousId, userId); } } else { ssrcMap.put(ssrc, userId); //Only create a decoder if we are actively handling received audio. if (receiveThread != null && AudioNatives.ensureOpus()) opusDecoders.put(ssrc, new Decoder(ssrc)); } }
return Templates.command.join.already_there.formatGuild(channel); if (!PermissionUtil.checkPermission(voiceChannel, voiceChannel.getGuild().getSelfMember(), Permission.VOICE_CONNECT, Permission.VOICE_SPEAK)) { return Templates.music.join_no_permission.formatGuild(channel, voiceChannel.getName()); VoiceChannel targetChannel = null; for (VoiceChannel vc : chan.getGuild().getVoiceChannels()) { if (vc.getName().equalsIgnoreCase(channelname)) { targetChannel = vc; break; return Templates.command.join.already_there.formatGuild(channel); if (!PermissionUtil.checkPermission(targetChannel, targetChannel.getGuild().getSelfMember(), Permission.VOICE_CONNECT, Permission.VOICE_SPEAK)) { return Templates.music.join_no_permission.formatGuild(channel, targetChannel.getName());
public AudioConnection(AudioManagerImpl manager, String endpoint, String sessionId, String token) { VoiceChannel channel = manager.getQueuedAudioConnection(); this.channel = new UpstreamReference<>(channel); final JDAImpl api = (JDAImpl) channel.getJDA(); this.api = new UpstreamReference<>(api); this.threadIdentifier = api.getIdentifierString() + " AudioConnection Guild: " + channel.getGuild().getId(); this.webSocket = new AudioWebSocket(this, manager.getListenerProxy(), endpoint, channel.getGuild(), sessionId, token, manager.isAutoReconnect()); }
public VoiceChannelUpdateUserLimitEvent(JDA api, long responseNumber, VoiceChannel channel, int oldUserLimit) { super(api, responseNumber, channel); this.oldUserLimit = oldUserLimit; this.newUserLimit = channel.getUserLimit(); }
public VoiceChannelUpdateBitrateEvent(JDA api, long responseNumber, VoiceChannel channel, int oldBitrate) { super(api, responseNumber, channel); this.oldBitrate = oldBitrate; this.newBitrate = channel.getBitrate(); }