aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.gradle4
-rw-r--r--src/main/java/soundchan/AudioPlayerSendHandler.java11
-rw-r--r--src/main/java/soundchan/BotListener/BotListener.java32
-rw-r--r--src/main/java/soundchan/BotListener/BotListenerHelpers.java6
-rw-r--r--src/main/java/soundchan/LocalAudioManager.java2
-rw-r--r--src/main/java/soundchan/Main.java13
6 files changed, 32 insertions, 36 deletions
diff --git a/build.gradle b/build.gradle
index befa0d3..c780e8b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -8,8 +8,8 @@ repositories {
}
dependencies {
- compile 'net.dv8tion:JDA:3.5.1_339'
- compile 'com.sedmelluq:lavaplayer:1.3.20'
+ compile 'net.dv8tion:JDA:4.0.0_39'
+ compile 'com.sedmelluq:lavaplayer:1.3.22'
runtime 'ch.qos.logback:logback-classic:1.2.3'
}
diff --git a/src/main/java/soundchan/AudioPlayerSendHandler.java b/src/main/java/soundchan/AudioPlayerSendHandler.java
index 5e174ca..fdd9774 100644
--- a/src/main/java/soundchan/AudioPlayerSendHandler.java
+++ b/src/main/java/soundchan/AudioPlayerSendHandler.java
@@ -2,7 +2,9 @@ package soundchan;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
-import net.dv8tion.jda.core.audio.AudioSendHandler;
+import net.dv8tion.jda.api.audio.AudioSendHandler;
+
+import java.nio.ByteBuffer;
/**
* This is a wrapper around AudioPlayer which makes it behave as an AudioSendHandler for JDA. As JDA calls canProvide
@@ -30,15 +32,12 @@ public class AudioPlayerSendHandler implements AudioSendHandler {
}
@Override
- public byte[] provide20MsAudio() {
+ public ByteBuffer provide20MsAudio() {
if (lastFrame == null) {
lastFrame = audioPlayer.provide();
}
- byte[] data = lastFrame != null ? lastFrame.getData() : null;
- lastFrame = null;
-
- return data;
+ return ByteBuffer.wrap(lastFrame.getData());
}
@Override
diff --git a/src/main/java/soundchan/BotListener/BotListener.java b/src/main/java/soundchan/BotListener/BotListener.java
index 4864ae2..0bd920d 100644
--- a/src/main/java/soundchan/BotListener/BotListener.java
+++ b/src/main/java/soundchan/BotListener/BotListener.java
@@ -7,17 +7,17 @@ import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers;
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
-import com.sun.istack.internal.NotNull;
-import net.dv8tion.jda.client.events.call.voice.CallVoiceJoinEvent;
-import net.dv8tion.jda.core.entities.Guild;
-import net.dv8tion.jda.core.entities.MessageChannel;
-import net.dv8tion.jda.core.entities.VoiceChannel;
-import net.dv8tion.jda.core.events.guild.voice.GuildVoiceJoinEvent;
-import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent;
-import net.dv8tion.jda.core.events.guild.voice.GuildVoiceMoveEvent;
-import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
-import net.dv8tion.jda.core.hooks.ListenerAdapter;
-import net.dv8tion.jda.core.managers.AudioManager;
+
+import net.dv8tion.jda.api.entities.Guild;
+import net.dv8tion.jda.api.entities.MessageChannel;
+import net.dv8tion.jda.api.entities.VoiceChannel;
+import net.dv8tion.jda.api.events.guild.voice.GuildVoiceJoinEvent;
+import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
+import net.dv8tion.jda.api.events.guild.voice.GuildVoiceMoveEvent;
+import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
+import net.dv8tion.jda.api.hooks.ListenerAdapter;
+import net.dv8tion.jda.api.managers.AudioManager;
+import org.jetbrains.annotations.NotNull;
import soundchan.*;
import java.nio.file.WatchEvent;
@@ -109,11 +109,6 @@ public class BotListener extends ListenerAdapter{
return musicManager;
}
- @Override
- public void onCallVoiceJoin(CallVoiceJoinEvent event){
- super.onCallVoiceJoin(event);
- }
-
/**
* Plays an audio clip when a user connects to the voice channel if enabled in the config file. For the sound to play,
* there needs to be a sound file with the same name as the user, otherwise it won't play anything.
@@ -195,7 +190,10 @@ public class BotListener extends ListenerAdapter{
public void onMessageReceived(MessageReceivedEvent event) {
String[] command = event.getMessage().getContentRaw().split(" ", 2);
- Guild guild = event.getGuild();
+ Guild guild = null;
+ if(event.isFromGuild()) {
+ guild = event.getGuild();
+ }
MessageChannel channel = helper.GetReplyChannel(event);
// If we haven't set the Monitored Guild yet, set the value
diff --git a/src/main/java/soundchan/BotListener/BotListenerHelpers.java b/src/main/java/soundchan/BotListener/BotListenerHelpers.java
index 98ad31a..4c589a3 100644
--- a/src/main/java/soundchan/BotListener/BotListenerHelpers.java
+++ b/src/main/java/soundchan/BotListener/BotListenerHelpers.java
@@ -1,8 +1,8 @@
package soundchan.BotListener;
-import net.dv8tion.jda.core.entities.Guild;
-import net.dv8tion.jda.core.entities.MessageChannel;
-import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
+import net.dv8tion.jda.api.entities.Guild;
+import net.dv8tion.jda.api.entities.MessageChannel;
+import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
public class BotListenerHelpers {
diff --git a/src/main/java/soundchan/LocalAudioManager.java b/src/main/java/soundchan/LocalAudioManager.java
index ea5b317..4db7010 100644
--- a/src/main/java/soundchan/LocalAudioManager.java
+++ b/src/main/java/soundchan/LocalAudioManager.java
@@ -1,6 +1,6 @@
package soundchan;
-import net.dv8tion.jda.core.entities.MessageChannel;
+import net.dv8tion.jda.api.entities.MessageChannel;
import java.io.File;
import java.io.FileInputStream;
diff --git a/src/main/java/soundchan/Main.java b/src/main/java/soundchan/Main.java
index a7aa6a3..587c7e9 100644
--- a/src/main/java/soundchan/Main.java
+++ b/src/main/java/soundchan/Main.java
@@ -1,8 +1,8 @@
package soundchan;
-import net.dv8tion.jda.core.AccountType;
-import net.dv8tion.jda.core.JDA;
-import net.dv8tion.jda.core.JDABuilder;
+import net.dv8tion.jda.api.AccountType;
+import net.dv8tion.jda.api.JDA;
+import net.dv8tion.jda.api.JDABuilder;
import soundchan.BotListener.*;
import java.io.FileInputStream;
@@ -17,10 +17,9 @@ public class Main {
JDA jda = new JDABuilder(AccountType.BOT)
.setToken(properties.getProperty("botToken"))
- .buildBlocking();
-
-
- jda.addEventListener(new BotListener(properties));
+ .addEventListeners(new BotListener(properties))
+ .build();
+ jda.awaitReady();
}
private static Properties LoadProperties(){