/** * 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; }
.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);
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)); } }
"for the destination VoiceChannel, so the move cannot be done."); JSONObject body = new JSONObject().put("channel_id", voiceChannel.getId()); Route.CompiledRoute route = Route.Guilds.MODIFY_MEMBER.compile(getGuild().getId(), member.getUser().getId());
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; }
@Override public String fromInput(Guild guild, String value) { if (allowNull && (value == null || value.isEmpty() || value.equalsIgnoreCase("false"))) { return ""; } if (DisUtil.isChannelMention(value)) { VoiceChannel channel = guild.getVoiceChannelById(DisUtil.mentionToId(value)); if (channel != null) { return channel.getId(); } } VoiceChannel channel = DisUtil.findVoiceChannel(guild, value); if (channel != null) { return channel.getId(); } return ""; }
private boolean canVoteSkip(CommandMessage message) { GuildVoiceState voiceState = message.getMember().getVoiceState(); GuildVoiceState selfVoteState = message.getGuild().getSelfMember().getVoiceState(); return voiceState.getChannel() != null && selfVoteState.getChannel() != null && voiceState.getChannel().getId().equals(selfVoteState.getChannel().getId()); } }
public static void removeGuild(Guild guild, boolean saveStatus) { if (playerInstances.containsKey(guild.getIdLong())) { if (saveStatus && playerInstances.get(guild.getIdLong()).isConnected()) { CBotPlayingOn.insert(guild.getId(), guild.getAudioManager().getConnectedChannel().getId()); } playerInstances.get(guild.getIdLong()).leave(); playerInstances.remove(guild.getIdLong()); } }
public void onVoiceChannelDelete(VoiceChannelDeleteEvent event) { GuildTransformer transformer = GuildController.fetchGuild(avaire, event.getGuild()); if (transformer == null) { return; } if (transformer.getMusicChannelVoice() != null && transformer.getMusicChannelVoice().equals(event.getChannel().getId())) { setDatabaseColumnToNull(event.getGuild().getId(), "music_channel_voice"); } }
private void onGuildVoiceJoin(GuildVoiceJoinEvent event, @Nonnull GuildWrapper wrapper) { if (event.getGuild() == null) return; if (cannotHandle(wrapper, ModlogEvent.MEMBER_VOICE_JOIN)) return; ModlogHandler.getInstance().postToModlog(wrapper, ModlogEvent.MEMBER_VOICE_JOIN, event.getMember().getUser(), new MessageEmbed.Field("Channel", event.getChannelJoined().getName() + " (" + event.getChannelJoined().getId() + ")", true)); }
private void onGuildVoiceLeave(GuildVoiceLeaveEvent event, @Nonnull GuildWrapper wrapper) { if (event.getGuild() == null) return; if (cannotHandle(wrapper, ModlogEvent.MEMBER_VOICE_LEAVE)) return; ModlogHandler.getInstance().postToModlog(wrapper, ModlogEvent.MEMBER_VOICE_LEAVE, event.getMember().getUser(), new MessageEmbed.Field("Channel", event.getChannelLeft().getName() + " (" + event.getChannelLeft().getId() + ")", true)); }
@Override public void onGuildVoiceJoin(GuildVoiceJoinEvent event) { if (event.getMember().getUser().isBot()) { return; } MusicPlayerHandler player = MusicPlayerHandler.getFor(event.getGuild(), discordBot); if (player.isConnected()) { return; } String autoChannel = GuildSettings.get(event.getGuild()).getOrDefault(GSetting.MUSIC_CHANNEL_AUTO); if ("false".equalsIgnoreCase(autoChannel)) { return; } if (event.getChannelJoined().getId().equals(autoChannel) || event.getChannelJoined().getName().equalsIgnoreCase(autoChannel)) { player.connectTo(event.getChannelJoined()); player.playRandomSong(); } }
private boolean displayCurrentChannels(CommandMessage context) { TextChannel textChannel = getTextChannel(context); VoiceChannel voiceChannel = getVoiceChannel(context); context.makeInfo(context.i18n("field.message")) .setTitle(context.i18n("field.title")) .set("text", textChannel == null ? "Disabled" : textChannel.getAsMention() + " (ID: " + textChannel.getId() + ")") .set("voice", voiceChannel == null ? "Disabled" : voiceChannel.getName() + " (ID: " + voiceChannel.getId() + ")") .queue(); return true; }
/** * shutdown hook, closing connections * */ private static void shutdownHook() { if (botContainer != null) { for (DiscordBot discordBot : botContainer.getShards()) { for (Guild guild : discordBot.getJda().getGuilds()) { AudioManager audio = guild.getAudioManager(); if (audio.isConnected()) { CBotPlayingOn.insert(guild.getId(), audio.getConnectedChannel().getId()); } } discordBot.getJda().shutdown(); } } }
private boolean kickUser(CommandMessage context, Member user, String[] args) { String reason = generateMessage(args); String originalVoiceChannelName = user.getVoiceState().getChannel().getName(); String originalVoiceChannelId = user.getVoiceState().getChannel().getId(); context.getGuild().getController().createVoiceChannel("kick-" + user.getUser().getId()).queue(channel -> context.getGuild().getController().moveVoiceMember(user, (VoiceChannel) channel) .queue(empty -> channel.delete().queue((Consumer<Void>) aVoid -> { Modlog.log(avaire, context, new ModlogAction( ModlogType.VOICE_KICK, context.getAuthor(), user.getUser(), originalVoiceChannelName + " (ID: " + originalVoiceChannelId + ")\n" + reason ) ); context.makeSuccess(context.i18n("message")) .set("target", user.getUser().getName() + "#" + user.getUser().getDiscriminator()) .set("voiceChannel", originalVoiceChannelName) .set("reason", reason) .queue(ignoreMessage -> context.delete().queue(null, RestActionUtil.ignore)); }, RestActionUtil.ignore) ) ); return true; }