public VoiceChannelUpdateNameEvent(JDA api, long responseNumber, VoiceChannel channel, String oldName) { super(api, responseNumber, channel); this.oldName = oldName; this.newName = channel.getName(); }
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 toDisplay(Guild guild, String value) { if (value == null || value.isEmpty() || !value.matches("\\d{10,}")) { return Emojibet.X; } VoiceChannel voiceChannel = guild.getVoiceChannelById(value); if (voiceChannel != null) { return voiceChannel.getName(); } return Emojibet.X; } }
/** * find a voice channel by name * * @param guild the guild to search in * @param channelName the channel to search for * @return VoiceChannel || null */ public static VoiceChannel findVoiceChannel(Guild guild, String channelName) { for (VoiceChannel channel : guild.getVoiceChannels()) { if (channel.getName().equalsIgnoreCase(channelName)) { return channel; } } return null; }
private void onGuildVoiceMove(GuildVoiceMoveEvent event, @Nonnull GuildWrapper wrapper) { if (cannotHandle(wrapper, ModlogEvent.MEMBER_VOICE_MOVE)) return; ModlogHandler.getInstance().postToModlog(wrapper, ModlogEvent.MEMBER_VOICE_MOVE, event.getMember().getUser(), new MessageEmbed.Field("Channel", "`" + event.getChannelLeft().getName() + "` -> `" + event.getChannelJoined().getName() + "`", true)); }
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(); } }
"**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());
@Override protected void execute(CommandEvent event) { if(event.getArgs().isEmpty()) { event.reply(event.getClient().getError()+" Please include a voice channel or NONE"); return; } Settings s = event.getClient().getSettingsFor(event.getGuild()); if(event.getArgs().equalsIgnoreCase("none")) { s.setVoiceChannel(null); event.reply(event.getClient().getSuccess()+" Music can now be played in any channel"); } else { List<VoiceChannel> list = FinderUtil.findVoiceChannels(event.getArgs(), event.getGuild()); if(list.isEmpty()) event.reply(event.getClient().getWarning()+" No Voice Channels found matching \""+event.getArgs()+"\""); else if (list.size()>1) event.reply(event.getClient().getWarning()+FormatUtil.listOfVChannels(list, event.getArgs())); else { s.setVoiceChannel(list.get(0)); event.reply(event.getClient().getSuccess()+" Music can now only be played in **"+list.get(0).getName()+"**"); } } } }
"**AFK:**\n" + "Channel: " + guild.getAfkChannel().getName() + "\n" + "\n" + "Timeout: " +
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; }
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.music.join_no_permission.formatGuild(channel, targetChannel.getName());
if (!"false".equalsIgnoreCase(autoChannel) && channel.getName().equalsIgnoreCase(autoChannel)) { return;
@Override protected void execute(CommandEvent event) { Settings s = event.getClient().getSettingsFor(event.getGuild()); MessageBuilder builder = new MessageBuilder() .append(EMOJI + " **") .append(event.getSelfUser().getName()) .append("** settings:"); TextChannel tchan = s.getTextChannel(event.getGuild()); VoiceChannel vchan = s.getVoiceChannel(event.getGuild()); Role role = s.getRole(event.getGuild()); EmbedBuilder ebuilder = new EmbedBuilder() .setColor(event.getSelfMember().getColor()) .setDescription("Text Channel: "+(tchan==null ? "Any" : "**#"+tchan.getName()+"**") + "\nVoice Channel: "+(vchan==null ? "Any" : "**"+vchan.getName()+"**") + "\nDJ Role: "+(role==null ? "None" : "**"+role.getName()+"**") + "\nRepeat Mode: **"+(s.getRepeatMode() ? "On" : "Off")+"**" + "\nDefault Playlist: "+(s.getDefaultPlaylist()==null ? "None" : "**"+s.getDefaultPlaylist()+"**") ) .setFooter(event.getJDA().getGuilds().size()+" servers | " +event.getJDA().getGuilds().stream().filter(g -> g.getSelfMember().getVoiceState().inVoiceChannel()).count() +" audio connections", null); event.getChannel().sendMessage(builder.setEmbed(ebuilder.build()).build()).queue(); }
&& 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;
if(!userState.inVoiceChannel() || userState.isDeafened() || (current!=null && !userState.getChannel().equals(current))) event.replyError("You must be listening in "+(current==null ? "a voice channel" : "**"+current.getName()+"**")+" to use that!"); return; event.reply(event.getClient().getError()+" I am unable to connect to **"+userState.getChannel().getName()+"**!"); return;
AudioTrack track = audioPlayer.getPlayingTrack(); MessageBuilder mb = new MessageBuilder(); mb.append(FormatUtil.filter(manager.getBot().getConfig().getSuccess()+" **Now Playing in "+guild.getSelfMember().getVoiceState().getChannel().getName()+"...**")); EmbedBuilder eb = new EmbedBuilder(); eb.setColor(guild.getSelfMember().getColor());
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; }
.set("channelName", channel.getName()) .queue(message -> message.delete().queueAfter(1, TimeUnit.MINUTES, null, RestActionUtil.ignore));