diff --git a/README.md b/README.md
index c79dcb5..e836011 100644
--- a/README.md
+++ b/README.md
@@ -14,4 +14,4 @@ To compile this maven project into jar file, write it in console (don't forget t
You will see compiled jar file in target folder, you also need to copy your .env file with your parameters in target folder.
-To open jar file you have to write `java -jar TouhouClub-1.5.jar` in console (you have to be in the same directory as the jar file).
+To open jar file you have to write `java -jar TouhouClub-1.6.jar` in console (you have to be in the same directory as the jar file).
diff --git a/pom.xml b/pom.xml
index 463d044..dbb4d77 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
ru.niron3206
TouhouClub
- 1.5
+ 1.6
UTF-8
@@ -24,23 +24,37 @@
m2-dv8tion
https://m2.dv8tion.net/releases
+
+ arbjergDev-releases
+ Lavalink Repository
+ https://maven.lavalink.dev/releases
+
+
com.github.DV8FromTheWorld
JDA
- v5.0.0-beta.17
+ v5.0.0-beta.23
+
+
+
+ dev.arbjerg
+ lavaplayer
+ 2.1.2
+
+ dev.lavalink.youtube
+ v2
+ 1.1.0
+
+
+
io.github.cdimascio
dotenv-java
2.3.1
-
- com.sedmelluq
- lavaplayer
- 1.3.77
-
org.slf4j
slf4j-api
@@ -70,10 +84,10 @@
+
org.apache.maven.plugins
maven-dependency-plugin
- 3.3.0
copy-dependencies
diff --git a/src/main/java/ru/niron3206/audioplayer/AutoLeave.java b/src/main/java/ru/niron3206/audioplayer/AutoLeave.java
index 7330986..b03047f 100644
--- a/src/main/java/ru/niron3206/audioplayer/AutoLeave.java
+++ b/src/main/java/ru/niron3206/audioplayer/AutoLeave.java
@@ -2,6 +2,7 @@
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.GuildVoiceState;
+import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import java.util.Timer;
import java.util.TimerTask;
@@ -16,16 +17,19 @@ public AutoLeave(Guild guild) {
public void timer() {
MusicManager musicManager = PlayerManager.getInstance().getMusicManager(guild);
+
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
GuildVoiceState selfVoiceState = guild.getSelfMember().getVoiceState();
- System.out.println("I'm in voice chat (ID: " + selfVoiceState.getChannel().getId() + ")");
+ VoiceChannel channel = selfVoiceState.getChannel().asVoiceChannel();
+
+ System.out.println("I'm in voice chat (ID: " + channel.getId() + ")");
if ((musicManager.audioPlayer.getPlayingTrack() == null
&& musicManager.scheduler.queue.isEmpty())
- || selfVoiceState.getChannel().asVoiceChannel().getMembers().isEmpty()) {
+ || channel.getMembers().isEmpty()) {
musicManager.scheduler.looping = false;
musicManager.audioPlayer.stopTrack();
guild.getAudioManager().closeAudioConnection();
diff --git a/src/main/java/ru/niron3206/audioplayer/PlayerManager.java b/src/main/java/ru/niron3206/audioplayer/PlayerManager.java
index 8b06ea3..0fddbc2 100644
--- a/src/main/java/ru/niron3206/audioplayer/PlayerManager.java
+++ b/src/main/java/ru/niron3206/audioplayer/PlayerManager.java
@@ -7,6 +7,7 @@
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
+import dev.lavalink.youtube.YoutubeAudioSourceManager;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
@@ -24,6 +25,9 @@ public PlayerManager() {
this.musicManager = new HashMap<>();
this.audioPlayerManager = new DefaultAudioPlayerManager();
+ YoutubeAudioSourceManager youtube = new YoutubeAudioSourceManager();
+ audioPlayerManager.registerSourceManager(youtube);
+
AudioSourceManagers.registerRemoteSources(audioPlayerManager);
AudioSourceManagers.registerLocalSource(audioPlayerManager);
}
@@ -93,7 +97,7 @@ public void noMatches() {
@Override
public void loadFailed(FriendlyException e) {
- //
+ e.printStackTrace();
}
});
}
diff --git a/src/main/java/ru/niron3206/cmds/music/PlayCommand.java b/src/main/java/ru/niron3206/cmds/music/PlayCommand.java
index 2b4fc79..212f8ad 100644
--- a/src/main/java/ru/niron3206/cmds/music/PlayCommand.java
+++ b/src/main/java/ru/niron3206/cmds/music/PlayCommand.java
@@ -26,7 +26,7 @@ public void handle(CommandContext ctx) {
TextChannel channel = ctx.getEvent().getChannel().asTextChannel();
List attachments = ctx.getEvent().getMessage().getAttachments();
- if (ctx.getArgs() == null && attachments.size() == 0) {
+ if (ctx.getArgs() == null && attachments.isEmpty()) {
channel.sendMessage("\uD83D\uDD34 Ничего не понял, вот как должно быть: `~play <ютуб ссылка, ссылка на аудио или прикреплённый аудиофайл>`").queue();
return;
}