From c7ab883d5ed6bae61db12ee33ed877549990369a Mon Sep 17 00:00:00 2001 From: Nekojimi Date: Sat, 4 Mar 2023 01:08:30 +0000 Subject: [PATCH] Update JDA to v5.0. --- pom.xml | 2 +- src/main/java/moe/nekojimi/chords/Chords.java | 13 +++++++------ .../moe/nekojimi/chords/commands/Invocation.java | 8 ++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 53692a9..ee10c41 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.dv8tion JDA - 5.0.0-beta.5 + 5.0.0-beta.6 commons-io diff --git a/src/main/java/moe/nekojimi/chords/Chords.java b/src/main/java/moe/nekojimi/chords/Chords.java index 9d8f4d2..452ff91 100644 --- a/src/main/java/moe/nekojimi/chords/Chords.java +++ b/src/main/java/moe/nekojimi/chords/Chords.java @@ -28,9 +28,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; -import net.dv8tion.jda.api.entities.channel.unions.AudioChannelUnion; import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.managers.AudioManager; import net.dv8tion.jda.api.requests.GatewayIntent; @@ -103,6 +103,7 @@ public final class Chords extends ListenerAdapter builder.setCompression(Compression.NONE); // Set activity (like "playing Something") builder.setActivity(Activity.playing("music!")); + builder.enableIntents(GatewayIntent.MESSAGE_CONTENT); final Chords listener = new Chords(); @@ -187,13 +188,13 @@ public final class Chords extends ListenerAdapter if (this.currentVoiceChannel == null) return; - final AudioChannelUnion channelLeft = event.getChannelLeft(); - - if (channelLeft.getMembers().isEmpty()) - if (channelLeft == currentVoiceChannel) + final AudioChannel channelLeft = event.getChannelLeft(); + if (channelLeft != null && channelLeft == currentVoiceChannel) + { + if (channelLeft.getMembers().isEmpty()) disconnect(); + } } - @Override public void onMessageReceived(MessageReceivedEvent event) { diff --git a/src/main/java/moe/nekojimi/chords/commands/Invocation.java b/src/main/java/moe/nekojimi/chords/commands/Invocation.java index 669a66d..f57da97 100644 --- a/src/main/java/moe/nekojimi/chords/commands/Invocation.java +++ b/src/main/java/moe/nekojimi/chords/commands/Invocation.java @@ -19,7 +19,6 @@ package moe.nekojimi.chords.commands; import java.util.List; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; -import net.dv8tion.jda.api.requests.FluentRestAction; import net.dv8tion.jda.api.requests.restaction.MessageCreateAction; /** @@ -54,17 +53,14 @@ public class Invocation @SuppressWarnings("null") public void respond(String text) { - FluentRestAction action = null; if (responseMessage == null) { - action = requestMessage.reply(text); + responseMessage = requestMessage.reply(text).complete(); } else { - action = responseMessage.editMessage(text); + responseMessage = responseMessage.editMessage(text).complete(); } - - responseMessage = action.complete(); } public Message getRequestMessage()