Update JDA to v5.0.

jda-v5
Nekojimi 2 years ago
parent 490101fcad
commit c7ab883d5e
  1. 2
      pom.xml
  2. 13
      src/main/java/moe/nekojimi/chords/Chords.java
  3. 8
      src/main/java/moe/nekojimi/chords/commands/Invocation.java

@ -35,7 +35,7 @@
<dependency> <dependency>
<groupId>net.dv8tion</groupId> <groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId> <artifactId>JDA</artifactId>
<version>5.0.0-beta.5</version> <version>5.0.0-beta.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>

@ -28,9 +28,9 @@ import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; 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.guild.voice.GuildVoiceUpdateEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; 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.hooks.ListenerAdapter;
import net.dv8tion.jda.api.managers.AudioManager; import net.dv8tion.jda.api.managers.AudioManager;
import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.requests.GatewayIntent;
@ -103,6 +103,7 @@ public final class Chords extends ListenerAdapter
builder.setCompression(Compression.NONE); builder.setCompression(Compression.NONE);
// Set activity (like "playing Something") // Set activity (like "playing Something")
builder.setActivity(Activity.playing("music!")); builder.setActivity(Activity.playing("music!"));
builder.enableIntents(GatewayIntent.MESSAGE_CONTENT);
final Chords listener = new Chords(); final Chords listener = new Chords();
@ -187,13 +188,13 @@ public final class Chords extends ListenerAdapter
if (this.currentVoiceChannel == null) if (this.currentVoiceChannel == null)
return; return;
final AudioChannelUnion channelLeft = event.getChannelLeft(); final AudioChannel channelLeft = event.getChannelLeft();
if (channelLeft != null && channelLeft == currentVoiceChannel)
if (channelLeft.getMembers().isEmpty()) {
if (channelLeft == currentVoiceChannel) if (channelLeft.getMembers().isEmpty())
disconnect(); disconnect();
}
} }
@Override @Override
public void onMessageReceived(MessageReceivedEvent event) public void onMessageReceived(MessageReceivedEvent event)
{ {

@ -19,7 +19,6 @@ package moe.nekojimi.chords.commands;
import java.util.List; import java.util.List;
import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.requests.FluentRestAction;
import net.dv8tion.jda.api.requests.restaction.MessageCreateAction; import net.dv8tion.jda.api.requests.restaction.MessageCreateAction;
/** /**
@ -54,17 +53,14 @@ public class Invocation
@SuppressWarnings("null") @SuppressWarnings("null")
public void respond(String text) public void respond(String text)
{ {
FluentRestAction<Message, ?> action = null;
if (responseMessage == null) if (responseMessage == null)
{ {
action = requestMessage.reply(text); responseMessage = requestMessage.reply(text).complete();
} else } else
{ {
action = responseMessage.editMessage(text); responseMessage = responseMessage.editMessage(text).complete();
} }
responseMessage = action.complete();
} }
public Message getRequestMessage() public Message getRequestMessage()

Loading…
Cancel
Save