From abbdaa5c37ea09c8cd4c5b6cb3b07d856ae565f3 Mon Sep 17 00:00:00 2001 From: MadeYoga Date: Thu, 17 Dec 2020 11:03:30 +0700 Subject: [PATCH] Update JDA version and fix some voice issues --- build.gradle | 2 +- src/main/java/command/music/ShowGuildStateCommand.java | 10 ++++++++-- .../java/command/music/ShowPaginatedQueueCommand.java | 10 ++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index a861d9a..f9ab559 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ repositories { dependencies { compile 'org.discordbots:DBL-Java-Library:2.0.1' - compile 'net.dv8tion:JDA:4.2.0_206' + compile 'net.dv8tion:JDA:4.2.0_222' compile 'com.jagrosh:jda-utilities:3.0.4' compile group: 'commons-validator', name: 'commons-validator', version: '1.4.0' compile 'joda-time:joda-time:2.10.6' diff --git a/src/main/java/command/music/ShowGuildStateCommand.java b/src/main/java/command/music/ShowGuildStateCommand.java index 8a2c1c6..a11e638 100644 --- a/src/main/java/command/music/ShowGuildStateCommand.java +++ b/src/main/java/command/music/ShowGuildStateCommand.java @@ -5,6 +5,7 @@ import com.jagrosh.jdautilities.command.CommandEvent; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.VoiceChannel; import service.music.CustomEmbedBuilder; import service.music.GuildMusicManager; import service.music.HelpProcess; @@ -27,10 +28,15 @@ public ShowGuildStateCommand(NanoClient nanoClient) { @Override protected void execute(CommandEvent event) { - // Ensure Voice - if (!nanoClient.getMusicService().ensureVoiceState(event)) { + VoiceChannel channel = event.getGuild().getAudioManager().getConnectedChannel(); + if (channel == null) { + event.reply("Not playing anything"); return; } + // Ensure Voice +// if (!nanoClient.getMusicService().ensureVoiceState(event)) { +// return; +// } GuildMusicManager musicManager = nanoClient.getGuildAudioPlayer(event.getGuild()); if (musicManager.player.getPlayingTrack() == null) { diff --git a/src/main/java/command/music/ShowPaginatedQueueCommand.java b/src/main/java/command/music/ShowPaginatedQueueCommand.java index 77ce01f..f69de4c 100644 --- a/src/main/java/command/music/ShowPaginatedQueueCommand.java +++ b/src/main/java/command/music/ShowPaginatedQueueCommand.java @@ -6,6 +6,7 @@ import com.jagrosh.jdautilities.menu.Paginator; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.VoiceChannel; import net.dv8tion.jda.api.exceptions.PermissionException; import service.music.GuildMusicManager; import service.music.HelpProcess; @@ -31,10 +32,15 @@ public ShowPaginatedQueueCommand(NanoClient nanoClient) { @Override protected void execute(CommandEvent event) { - // Ensure Voice - if (!nanoClient.getMusicService().ensureVoiceState(event)) { + VoiceChannel channel = event.getGuild().getAudioManager().getConnectedChannel(); + if (channel == null) { + event.reply("Not playing anything"); return; } + // Ensure Voice +// if (!nanoClient.getMusicService().ensureVoiceState(event)) { +// return; +// } GuildMusicManager musicManager = nanoClient.getGuildAudioPlayer(event.getGuild()); if (musicManager.player.getPlayingTrack() == null) {