public void setChannel(VoiceChannel channel) { this.channelId = channel.getIdLong(); }
@Override public boolean equals(Object o) { if (!(o instanceof VoiceChannel)) return false; VoiceChannel oVChannel = (VoiceChannel) o; return this == oVChannel || this.getIdLong() == oVChannel.getIdLong(); }
public ConnectionRequest(VoiceChannel channel, ConnectionStage stage) { this.channelId = channel.getIdLong(); this.guildId = channel.getGuild().getIdLong(); this.stage = stage; this.nextAttemptEpoch = System.currentTimeMillis(); }
@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()); }
if (request.getChannelId() == connectedChannel.getIdLong()) return queuedAudioConnections.remove(guildId);
public void setVoiceChannel(VoiceChannel vc) { this.voiceId = vc == null ? 0 : vc.getIdLong(); this.manager.writeSettings(); }
if (connGuild != null) if (connGuild.getVoiceChannelById(audioConnection.getChannel().getIdLong()) == null) status = ConnectionStatus.DISCONNECTED_CHANNEL_DELETED;
@SuppressWarnings("SimplifiableIfStatement") public boolean canPreformSpecialAction(@Nonnull Command command, @Nonnull CommandMessage context, @Nonnull String action) { if (context.getMember().hasPermission(Permission.ADMINISTRATOR)) { return true; } VoiceChannel channel = context.getMember().getVoiceState().getChannel(); if (channel == null) { return command.sendErrorMessage(context, "errors.mustBeConnectedToVoice"); } VoiceChannel selfChannel = context.getGuild().getSelfMember().getVoiceState().getChannel(); if (selfChannel == null || selfChannel.getIdLong() != channel.getIdLong()) { return command.sendErrorMessage(context, "errors.mustBeConnectedToSameChannel", action); } return true; }
cleanup(guild, FlareBot.instance().getMusicManager().getPlayer(guild.getId()), vc.getIdLong()); } else if (isPlayingMusic(vc)) { VC_LAST_USED.put(vc.getIdLong(), System.currentTimeMillis()); } else { if (!VC_LAST_USED.containsKey(vc.getIdLong())) { VC_LAST_USED.put(vc.getIdLong(), System.currentTimeMillis()); return; long lastUsed = VC_LAST_USED.get(vc.getIdLong()); cleanup(guild, FlareBot.instance().getMusicManager().getPlayer(guild.getId()), vc.getIdLong());
guild.getVoiceChannelCache().forEach(chan -> getJDA().getVoiceChannelMap().remove(chan.getIdLong())); guild.getCategoryCache().forEach(chan -> getJDA().getCategoryMap().remove(chan.getIdLong()));
@Override public void onGuildVoiceMove(GuildVoiceMoveEvent event) { if (!(event.getMember() == event.getGuild().getSelfMember())) { return; // user is not self } GuildAudioController musicManager = guildAudioManager.get(event.getGuild().getIdLong()); if (musicManager == null) { return; // this guild doesn't have a music manager so doesnt matter } VoiceChannel joinedChannel = event.getChannelJoined(); musicManager.getState().setVoiceConnectionOpen(joinedChannel.getIdLong()); // update the voice channel for this guild LOGGER.info("Moved from voice channel {} to {}. Updated GuildAudioController.", event.getChannelLeft().toString(), joinedChannel.toString()); } }
state.setVoiceConnectionOpen(voiceChannel.getIdLong()); } finally { lock.unlock();
/** * Creates the audio state by copying the currently playing track, the volume, * voice and channel IDs used for the music, guild ID, as well as all the * tracks in the queue, the audio state can be used when the bot shuts * down, to save it all the cache, or when the bot starts back up * again, to load everything back into the music player. * * @param musicManager The guild music manager that the audio state should be created for. * @param guild The JDA guild object for the current guild music manager. */ public AudioState(GuildMusicManager musicManager, Guild guild) { this.volume = musicManager.getPlayer().getVolume(); this.guildId = guild.getIdLong(); VoiceChannel channel = LavalinkManager.LavalinkManagerHolder.lavalink.getConnectedChannel(guild); voiceChannelId = channel != null ? channel.getIdLong() : 0L; messageChannelId = musicManager.getLastActiveMessage() != null ? musicManager.getLastActiveMessage().getChannel().getIdLong() : 0L; AudioTrack playingTrack = musicManager.getPlayer().getPlayingTrack(); AudioTrackContainer container = musicManager.getScheduler().getAudioTrackContainer(); this.playingTrack = playingTrack == null ? null : new AudioCache( playingTrack.getInfo().uri, container != null ? container.getRequester().getIdLong() : 0L, playingTrack.getPosition() ); musicManager.getScheduler().getQueue().stream() .map(AudioCache::new) .forEach(queue::add); }
@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()); } }
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());
@Override public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) { if (event.getMember().getUser().getIdLong() == event.getJDA().getSelfUser().getIdLong()) { if (flareBot.getMusicManager().hasPlayer(event.getGuild().getId())) { flareBot.getMusicManager().getPlayer(event.getGuild().getId()).setPaused(true); } if (Getters.getActiveVoiceChannels() == 0 && FlareBot.NOVOICE_UPDATING.get()) { Constants.getImportantLogChannel() .sendMessage("I am now updating, there are no voice channels active!").queue(); UpdateCommand.update(true, null); } } else { handleVoiceConnectivity(event.getChannelLeft()); } if (event.getMember().getUser().equals(event.getJDA().getSelfUser())) return; if (VoteUtil.contains(SkipCommand.getSkipUUID(), event.getGuild()) && event.getChannelLeft().getIdLong() == event.getGuild().getSelfMember().getVoiceState().getChannel().getIdLong()) { VoteUtil.getVoteGroup(SkipCommand.getSkipUUID(), event.getGuild()).remoreAllowedUser(event.getMember().getUser()); } }
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());