public GuildVoiceJoinEvent(JDA api, long responseNumber, Member member) { super(api, responseNumber, member); this.channelJoined = member.getVoiceState().getChannel(); }
if (vState == null) throw new IllegalStateException("Cannot move a Member with disabled CacheFlag.VOICE_STATE"); if (!vState.inVoiceChannel()) throw new IllegalStateException("You cannot move a Member who isn't in a VoiceChannel!"); if (!PermissionUtil.checkPermission(vState.getChannel(), getGuild().getSelfMember(), Permission.VOICE_MOVE_OTHERS)) throw new InsufficientPermissionException(Permission.VOICE_MOVE_OTHERS, "This account does not have Permission to MOVE_OTHERS out of the channel that the Member is currently in.");
public GuildVoiceDeafenEvent(JDA api, long responseNumber, Member member) { super(api, responseNumber, member); this.deafened = member.getVoiceState().isDeafened(); }
throw new IllegalArgumentException("Attempted to start audio connection with Guild that doesn't exist!"); getJDA().getClient().updateAudioConnection(guildId, guild.getSelfMember().getVoiceState().getChannel()); String sessionId = guild.getSelfMember().getVoiceState().getSessionId(); if (sessionId == null) throw new IllegalArgumentException("Attempted to create audio connection without having a session ID. Did VOICE_STATE_UPDATED fail?");
VoiceChannel current = event.getGuild().getSelfMember().getVoiceState().getChannel(); if(current==null) current = settings.getVoiceChannel(event.getGuild()); GuildVoiceState userState = event.getMember().getVoiceState(); if(!userState.inVoiceChannel() || userState.isDeafened() || (current!=null && !userState.getChannel().equals(current))) if(!event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) event.getGuild().getAudioManager().openAudioConnection(userState.getChannel()); event.reply(event.getClient().getError()+" I am unable to connect to **"+userState.getChannel().getName()+"**!"); return;
int listeners = (int)event.getSelfMember().getVoiceState().getChannel().getMembers().stream() .filter(m -> !m.getUser().isBot() && !m.getVoiceState().isDeafened()).count(); String msg; if(handler.getVotes().contains(event.getAuthor().getId())) handler.getVotes().add(event.getAuthor().getId()); int skippers = (int)event.getSelfMember().getVoiceState().getChannel().getMembers().stream() .filter(m -> handler.getVotes().contains(m.getUser().getId())).count(); int required = (int)Math.ceil(listeners * .55);
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (channel.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) { if ((!member.getVoiceState().inVoiceChannel() || !channel.getGuild().getSelfMember().getVoiceState() .getAudioChannel().getId() .equals(member.getVoiceState().getAudioChannel() .getId())) && !getPermissions(channel) .hasPermission(member, Permission.LEAVE_OTHER)) { MessageUtils.sendErrorMessage("You need the permission `" + Permission.LEAVE_OTHER + "` for me to leave a different voice channel!", channel, sender); return; } channel.getGuild().getAudioManager().closeAudioConnection(); if (FlareBotManager.instance().getLastActive().containsKey(guild.getGuildIdLong())) FlareBotManager.instance().getLastActive().remove(guild.getGuildIdLong()); MessageUtils.sendInfoMessage("Bye bye! I've left the channel for now", channel, sender); } }
if (member.getVoiceState().isDeafened()) { continue; if (hasListeners && !manager.getGuild().getSelfMember().getVoiceState().isMuted()) { missingListener.remove(guildId); continue;
public boolean isMusicPlaying(JDA jda) { return guild(jda).getSelfMember().getVoiceState().inVoiceChannel() && audioPlayer.getPlayingTrack()!=null; }
public GuildVoiceMuteEvent(JDA api, long responseNumber, Member member) { super(api, responseNumber, member); this.muted = member.getVoiceState().isMuted(); }
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (member.getVoiceState().inVoiceChannel()) { if (channel.getGuild().getAudioManager().isAttemptingToConnect()) { MessageUtils.sendErrorMessage("Currently connecting to a voice channel! Try again soon!", channel); return; } if (channel.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && !channel.getGuild() .getSelfMember() .getVoiceState() .getAudioChannel() .getId() .equals(member .getVoiceState() .getAudioChannel() .getId()) && !getPermissions(channel).hasPermission(member, Permission.JOIN_OTHER)) { MessageUtils.sendErrorMessage("You need the permission `" + Permission.JOIN_OTHER + "` for me to join your voice channel while I'm in one!", channel); return; } GuildUtils.joinChannel(channel, member); } }
if (member.getVoiceState().isDeafened()) { continue; if (hasListeners && !guildMusicManager.getLastActiveMessage().getGuild().getSelfMember().getVoiceState().isMuted()) { missingListener.remove(guildId); continue;
public void onTrackUpdate(long guildId, AudioTrack track, AudioHandler handler) { // update bot status if applicable if(bot.getConfig().getSongInStatus()) { if(track!=null && bot.getJDA().getGuilds().stream().filter(g -> g.getSelfMember().getVoiceState().inVoiceChannel()).count()<=1) bot.getJDA().getPresence().setGame(Game.listening(track.getInfo().title)); else bot.resetGame(); } // update channel topic if applicable updateTopic(guildId, handler, false); }
public GuildVoiceMoveEvent(JDA api, long responseNumber, Member member, VoiceChannel channelLeft) { super(api, responseNumber, member, channelLeft); this.channelJoined = member.getVoiceState().getChannel(); }
@Override public void onGuildVoiceJoin(GuildVoiceJoinEvent event) { if (event.getMember().getUser().equals(event.getJDA().getSelfUser()) && flareBot.getMusicManager() .hasPlayer(event.getGuild().getId())) { flareBot.getMusicManager().getPlayer(event.getGuild().getId()).setPaused(false); } if (event.getMember().getUser().equals(event.getJDA().getSelfUser())) return; if (event.getGuild().getSelfMember().getVoiceState().getChannel() == null) return; if (VoteUtil.contains(SkipCommand.getSkipUUID(), event.getGuild()) && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getChannelJoined().getIdLong() == event.getGuild().getSelfMember().getVoiceState().getChannel().getIdLong()) { VoteUtil.getVoteGroup(SkipCommand.getSkipUUID(), event.getGuild()).addAllowedUser(event.getMember().getUser()); } }
if (member.getVoiceState().inVoiceChannel()) { if (channel.getGuild().getAudioManager().isAttemptingToConnect()) { MessageUtils.sendErrorMessage("Currently connecting to a voice channel! Try again soon!", channel); return; if (channel.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && !(channel.getGuild().getSelfMember().getVoiceState().getAudioChannel().getId() .equals(member.getVoiceState().getAudioChannel().getId()))) { MessageUtils.sendErrorMessage("I cannot join your channel! I am already in a channel!", channel); return;
@Override public boolean onCommand(CommandMessage context, String[] args) { User user = MentionableUtil.getUser(context, args); if (user == null) { return sendErrorMessage(context, context.i18n("mustMentionUser")); } if (userHasHigherRole(user, context.getMember())) { return sendErrorMessage(context, context.i18n("sameOrHigherRole")); } final Member member = context.getGuild().getMember(user); if (!member.getVoiceState().inVoiceChannel()) { return sendErrorMessage(context, context.i18n("notConnected")); } return kickUser(context, member, args); }
/** * retrieves a list of users who can listen and use voice commands * generating images is easy to make messy * for now * * @return list of users */ public List<Member> getUsersInVoiceChannel() { ArrayList<Member> userList = new ArrayList<>(); VoiceChannel currentChannel = bot.getJda().getGuildById(guildId).getAudioManager().getConnectedChannel(); if (currentChannel != null) { List<Member> connectedUsers = currentChannel.getMembers(); userList.addAll(connectedUsers.stream().filter(user -> !user.getUser().isBot() && !user.getVoiceState().isDeafened() && GuildSettings.get(currentChannel.getGuild()).canUseMusicCommands(user.getUser(), bot.security.getSimpleRankForGuild(user.getUser(), currentChannel.getGuild())) ).collect(Collectors.toList())); } return userList; }
client.updateAudioConnection0(guild.getIdLong(), voiceState.getChannel());