From 809a0a610bcf11b338545a838293c97a0e3bfb95 Mon Sep 17 00:00:00 2001 From: Michail Date: Sat, 2 Mar 2024 12:02:45 +0100 Subject: [PATCH] Always self-deafen --- .../jmusicbot/commands/MusicCommand.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java b/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java index 9740a7af7..1e11fe11e 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java @@ -29,27 +29,27 @@ * * @author John Grosh */ -public abstract class MusicCommand extends Command +public abstract class MusicCommand extends Command { protected final Bot bot; protected boolean bePlaying; protected boolean beListening; - + public MusicCommand(Bot bot) { this.bot = bot; this.guildOnly = true; this.category = new Category("Music"); } - + @Override - protected void execute(CommandEvent event) + protected void execute(CommandEvent event) { Settings settings = event.getClient().getSettingsFor(event.getGuild()); TextChannel tchannel = settings.getTextChannel(event.getGuild()); if(tchannel!=null && !event.getTextChannel().equals(tchannel)) { - try + try { event.getMessage().delete().queue(); } catch(PermissionException ignore){} @@ -83,20 +83,21 @@ protected void execute(CommandEvent event) if(!event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) { - try + try { event.getGuild().getAudioManager().openAudioConnection(userState.getChannel()); + event.getGuild().getAudioManager().setSelfDeafened(true); } - catch(PermissionException ex) + catch(PermissionException ex) { event.reply(event.getClient().getError()+" I am unable to connect to "+userState.getChannel().getAsMention()+"!"); return; } } } - + doCommand(event); } - + public abstract void doCommand(CommandEvent event); }