From e08c1491c21a3413580c56e767cca81e5f53bd31 Mon Sep 17 00:00:00 2001 From: Louk <64579257+yo-louk@users.noreply.github.com> Date: Sat, 2 Oct 2021 21:17:00 +0200 Subject: [PATCH] Voice channel mention (#932) * Voice channel mention I recently noticed voice channels can be mentioned just like text channels. A small change to the code to implement this feature. * Voice channel mention * vc.getName() changed to vc.getAsMention() --- src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java | 2 +- .../java/com/jagrosh/jmusicbot/commands/MusicCommand.java | 4 ++-- .../java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java | 2 +- .../com/jagrosh/jmusicbot/commands/general/SettingsCmd.java | 2 +- src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java b/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java index ff7cb72f6..600f34eec 100644 --- a/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java +++ b/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java @@ -202,7 +202,7 @@ public Message getNowPlaying(JDA jda) Guild guild = guild(jda); AudioTrack track = audioPlayer.getPlayingTrack(); MessageBuilder mb = new MessageBuilder(); - mb.append(FormatUtil.filter(manager.getBot().getConfig().getSuccess()+" **Now Playing in "+guild.getSelfMember().getVoiceState().getChannel().getName()+"...**")); + mb.append(FormatUtil.filter(manager.getBot().getConfig().getSuccess()+" **Now Playing in "+guild.getSelfMember().getVoiceState().getChannel().getAsMention()+"...**")); EmbedBuilder eb = new EmbedBuilder(); eb.setColor(guild.getSelfMember().getColor()); RequestMetadata rm = getRequestMetadata(); diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java b/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java index b770958e4..9740a7af7 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java @@ -70,7 +70,7 @@ protected void execute(CommandEvent event) GuildVoiceState userState = event.getMember().getVoiceState(); 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!"); + event.replyError("You must be listening in "+(current==null ? "a voice channel" : current.getAsMention())+" to use that!"); return; } @@ -89,7 +89,7 @@ protected void execute(CommandEvent event) } catch(PermissionException ex) { - event.reply(event.getClient().getError()+" I am unable to connect to **"+userState.getChannel().getName()+"**!"); + event.reply(event.getClient().getError()+" I am unable to connect to "+userState.getChannel().getAsMention()+"!"); return; } } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java index c7d3c056d..e8f66639e 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java @@ -62,7 +62,7 @@ else if (list.size()>1) else { s.setVoiceChannel(list.get(0)); - event.reply(event.getClient().getSuccess()+" Music can now only be played in **"+list.get(0).getName()+"**"); + event.reply(event.getClient().getSuccess()+" Music can now only be played in "+list.get(0).getAsMention()); } } } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java index f701c68dd..7f88e0b2d 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java @@ -57,7 +57,7 @@ protected void execute(CommandEvent event) EmbedBuilder ebuilder = new EmbedBuilder() .setColor(event.getSelfMember().getColor()) .setDescription("Text Channel: " + (tchan == null ? "Any" : "**#" + tchan.getName() + "**") - + "\nVoice Channel: " + (vchan == null ? "Any" : "**" + vchan.getName() + "**") + + "\nVoice Channel: " + (vchan == null ? "Any" : vchan.getAsMention()) + "\nDJ Role: " + (role == null ? "None" : "**" + role.getName() + "**") + "\nCustom Prefix: " + (s.getPrefix() == null ? "None" : "`" + s.getPrefix() + "`") + "\nRepeat Mode: " + (s.getRepeatMode() == RepeatMode.OFF diff --git a/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java b/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java index 4e6b53cae..53d7d0401 100644 --- a/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java +++ b/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java @@ -74,7 +74,7 @@ public static String listOfVChannels(List list, String query) { String out = " Multiple voice channels found matching \""+query+"\":"; for(int i=0; i<6 && i6) out+="\n**And "+(list.size()-6)+" more...**"; return out;