diff --git a/pom.xml b/pom.xml
index af82e02b..c32497f1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,19 +54,14 @@
bintray
https://jcenter.bintray.com
+
+ ll-releases
+ Lavalink Releases
+ https://maven.lavalink.dev/releases
+
-
- dev.schlaubi.lavakord
- jda-jvm
- 5.1.7
-
-
- dev.schlaubi.lavakord
- lavasrc-jvm
- 6.0.0
-
ch.qos.logback
logback-classic
@@ -82,6 +77,11 @@
JDA
5.0.0-beta.17
+
+ dev.arbjerg
+ lavalink-client
+ 2.1.0
+
org.json
json
@@ -296,10 +296,6 @@
com.github.bombies
jda-ktx
-
- dev.schlaubi.lavakord
- jda-jvm
-
net.dv8tion
JDA
diff --git a/src/main/kotlin/api/routes/requestchannel/RequestChannelService.kt b/src/main/kotlin/api/routes/requestchannel/RequestChannelService.kt
index 5abae827..fc89f1c6 100644
--- a/src/main/kotlin/api/routes/requestchannel/RequestChannelService.kt
+++ b/src/main/kotlin/api/routes/requestchannel/RequestChannelService.kt
@@ -56,7 +56,6 @@ class RequestChannelService(shardManager: ShardManager) : AbstractGuildService(s
RequestChannelEditCommand()
.handleChannelButtonToggle(guild, listOf(dto.button.lowercase()), shardManager = shardManager)
- ?.await()
return OkResponse("Successfully toggled the ${dto.button} button in ${guild.name}")
}
diff --git a/src/main/kotlin/main/audiohandlers/GuildDisconnectManager.kt b/src/main/kotlin/main/audiohandlers/GuildDisconnectManager.kt
index 3c38671b..c1bbea89 100644
--- a/src/main/kotlin/main/audiohandlers/GuildDisconnectManager.kt
+++ b/src/main/kotlin/main/audiohandlers/GuildDisconnectManager.kt
@@ -23,7 +23,7 @@ class GuildDisconnectManager(private val guild: Guild) {
* @param announceMsg Whether the bot should announce that it has disconnected due to activity or not.
* @param duration The time the bot should wait before disconnect. Default to 5 minutes
*/
- suspend fun scheduleDisconnect(duration: Duration = 5.minutes, announceMsg: Boolean = true) {
+ fun scheduleDisconnect(duration: Duration = 5.minutes, announceMsg: Boolean = true) {
val botVoiceState = guild.selfMember.voiceState
if (botVoiceState == null || !botVoiceState.inAudioChannel())
return
diff --git a/src/main/kotlin/main/audiohandlers/GuildMusicManager.kt b/src/main/kotlin/main/audiohandlers/GuildMusicManager.kt
index 0139cad9..bae1339a 100644
--- a/src/main/kotlin/main/audiohandlers/GuildMusicManager.kt
+++ b/src/main/kotlin/main/audiohandlers/GuildMusicManager.kt
@@ -1,25 +1,35 @@
package main.audiohandlers
-import dev.schlaubi.lavakord.audio.Link
+import dev.arbjerg.lavalink.client.LavalinkPlayer
+import dev.arbjerg.lavalink.client.Link
+import dev.arbjerg.lavalink.protocol.v4.Filters
import main.commands.slashcommands.audio.SkipCommand
import main.main.Robertify
import main.utils.json.requestchannel.RequestChannelConfig
import net.dv8tion.jda.api.entities.Guild
class GuildMusicManager(val guild: Guild) {
- val link: Link = Robertify.lavaKord.getLink(guild.id)
- val player = link.player
+ val link: Link = Robertify.lavalink.getLink(guild.idLong)
val scheduler = TrackScheduler(guild, link)
val voteSkipManager = GuildVoteSkipManager()
+ val player: LavalinkPlayer?
+ get() = link.getPlayer().block()
var isForcePaused = false
- suspend fun clear() {
+ fun usePlayer(playerCallback: (LavalinkPlayer) -> Unit) {
+ link.getPlayer().subscribe(playerCallback)
+ }
+
+
+ fun clear() {
val queueHandler = scheduler.queueHandler
queueHandler.clear()
queueHandler.clearSavedQueue()
queueHandler.clearPreviousTracks()
- player.filters.reset()
+
+ link.createOrUpdatePlayer()
+ .setFilters(Filters())
queueHandler.trackRepeating = false
queueHandler.queueRepeating = false
@@ -29,13 +39,8 @@ class GuildMusicManager(val guild: Guild) {
RequestChannelConfig(guild).updateMessage()
}
- suspend fun leave() {
+ fun leave() {
clear()
RobertifyAudioManager.removeMusicManager(guild)
}
-
- suspend fun destroy() {
- if (link.state != Link.State.DESTROYED)
- link.destroy()
- }
}
\ No newline at end of file
diff --git a/src/main/kotlin/main/audiohandlers/QueueHandler.kt b/src/main/kotlin/main/audiohandlers/QueueHandler.kt
index c885050b..5e046f3b 100644
--- a/src/main/kotlin/main/audiohandlers/QueueHandler.kt
+++ b/src/main/kotlin/main/audiohandlers/QueueHandler.kt
@@ -1,6 +1,6 @@
package main.audiohandlers
-import dev.arbjerg.lavalink.protocol.v4.Track
+import dev.arbjerg.lavalink.client.protocol.Track
import java.util.Stack
import java.util.concurrent.ConcurrentLinkedQueue
diff --git a/src/main/kotlin/main/audiohandlers/RobertifyAudioManager.kt b/src/main/kotlin/main/audiohandlers/RobertifyAudioManager.kt
index 461b2230..07ecd046 100644
--- a/src/main/kotlin/main/audiohandlers/RobertifyAudioManager.kt
+++ b/src/main/kotlin/main/audiohandlers/RobertifyAudioManager.kt
@@ -9,8 +9,8 @@ import com.github.topi314.lavasrc.spotify.SpotifySourceManager
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager
import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers
+import dev.arbjerg.lavalink.client.LinkState
import dev.minn.jda.ktx.util.SLF4J
-import dev.schlaubi.lavakord.audio.Link
import main.audiohandlers.loaders.AutoPlayLoader
import main.audiohandlers.loaders.MainAudioLoader
import main.audiohandlers.loaders.SearchResultLoader
@@ -18,7 +18,6 @@ import main.constants.Toggle
import main.main.Config
import main.utils.RobertifyEmbedUtils
import main.utils.RobertifyEmbedUtils.Companion.editEmbed
-import main.utils.json.guildconfig.GuildConfig
import main.utils.json.restrictedchannels.RestrictedChannelsConfig
import main.utils.json.toggles.TogglesConfig
import main.utils.locale.LocaleManager
@@ -28,12 +27,10 @@ import net.dv8tion.jda.api.entities.Guild
import net.dv8tion.jda.api.entities.GuildVoiceState
import net.dv8tion.jda.api.entities.Message
import net.dv8tion.jda.api.entities.User
-import net.dv8tion.jda.api.entities.channel.ChannelType
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException
import net.dv8tion.jda.api.interactions.InteractionHook
-import java.lang.IllegalArgumentException
import java.util.*
object RobertifyAudioManager {
@@ -88,12 +85,12 @@ object RobertifyAudioManager {
fun getMusicManager(guild: Guild): GuildMusicManager = get(guild)
- suspend fun removeMusicManager(guild: Guild) {
- musicManagers[guild.idLong]?.destroy()
+ fun removeMusicManager(guild: Guild) {
musicManagers.remove(guild.idLong)
+ guild.jda.directAudioController.disconnect(guild)
}
- suspend fun loadAndPlay(
+ fun loadAndPlay(
trackUrl: String,
memberVoiceState: GuildVoiceState,
botMessage: Message? = null,
@@ -120,7 +117,7 @@ object RobertifyAudioManager {
}
}
-// suspend fun loadAndResume(musicManager: GuildMusicManager, data: ResumeData) {
+// fun loadAndResume(musicManager: GuildMusicManager, data: ResumeData) {
// val channelId = data.channel_id
// val voiceChannel = Robertify.shardManager.getVoiceChannelById(channelId)
//
@@ -137,7 +134,7 @@ object RobertifyAudioManager {
// else logger.warn("Could not resume tracks in ${musicManager.guild.name} because I couldn't join the voice channel!")
// }
//
-// private suspend fun resumeTracks(
+// private fun resumeTracks(
// trackList: List,
// announcementChannel: GuildMessageChannel?,
// musicManager: GuildMusicManager
@@ -156,7 +153,7 @@ object RobertifyAudioManager {
// ).loadItem()
// }
- private suspend fun loadTrack(
+ private fun loadTrack(
trackUrl: String,
musicManager: GuildMusicManager,
user: User,
@@ -176,7 +173,7 @@ object RobertifyAudioManager {
).loadItem()
}
- suspend fun loadSearchResults(
+ fun loadSearchResults(
musicManager: GuildMusicManager,
searcher: User,
botMessage: InteractionHook,
@@ -190,7 +187,7 @@ object RobertifyAudioManager {
).loadItem()
}
- suspend fun loadRecommendedTracks(
+ fun loadRecommendedTracks(
musicManager: GuildMusicManager,
channel: GuildMessageChannel?,
trackIds: String
@@ -211,7 +208,7 @@ object RobertifyAudioManager {
* @param message The message to edit for any error messages.
* @return True if the bot successfully joined the channel and vice-versa.
*/
- suspend fun joinAudioChannel(
+ fun joinAudioChannel(
channel: AudioChannel,
musicManager: GuildMusicManager,
message: Message? = null,
@@ -220,7 +217,7 @@ object RobertifyAudioManager {
try {
require(channel.members.size > 0) { "I can't join a voice channel with no one in it!" }
when (musicManager.link.state) {
- Link.State.DESTROYED, Link.State.NOT_CONNECTED -> {
+ LinkState.DISCONNECTED -> {
val guild = musicManager.guild
if (TogglesConfig(guild).getToggle(Toggle.RESTRICTED_VOICE_CHANNELS)) {
val restrictedChannelConfig = RestrictedChannelsConfig(guild)
@@ -268,7 +265,7 @@ object RobertifyAudioManager {
return true
}
- Link.State.CONNECTED, Link.State.CONNECTING -> return true
+ LinkState.CONNECTED, LinkState.CONNECTING -> return true
else -> {
return false
}
diff --git a/src/main/kotlin/main/audiohandlers/TrackScheduler.kt b/src/main/kotlin/main/audiohandlers/TrackScheduler.kt
index 595f5613..84fb2f50 100644
--- a/src/main/kotlin/main/audiohandlers/TrackScheduler.kt
+++ b/src/main/kotlin/main/audiohandlers/TrackScheduler.kt
@@ -1,23 +1,18 @@
package main.audiohandlers
-import dev.arbjerg.lavalink.protocol.v4.Track
+import dev.arbjerg.lavalink.client.*
+import dev.arbjerg.lavalink.client.protocol.Track
import dev.arbjerg.lavalink.protocol.v4.TrackInfo
-import dev.minn.jda.ktx.coroutines.await
-import dev.schlaubi.lavakord.audio.*
-import dev.schlaubi.lavakord.audio.player.Player
-import kotlinx.coroutines.*
-import kotlinx.coroutines.flow.launchIn
-import kotlinx.coroutines.flow.onEach
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.MissingFieldException
import main.audiohandlers.models.Requester
import main.audiohandlers.utils.artworkUrl
-import main.audiohandlers.utils.author
-import main.audiohandlers.utils.title
import main.commands.slashcommands.misc.PlaytimeCommand
import main.constants.Toggle
import main.main.Robertify
-import main.utils.GeneralUtils
+import main.utils.GeneralUtils.queueAfter
import main.utils.RobertifyEmbedUtils
import main.utils.api.robertify.imagebuilders.AbstractImageBuilder
import main.utils.api.robertify.imagebuilders.ImageBuilderException
@@ -45,79 +40,101 @@ import net.dv8tion.jda.api.utils.FileUpload
import org.slf4j.LoggerFactory
import java.io.InputStream
import java.util.concurrent.CompletableFuture
-import java.util.concurrent.CompletionException
import java.util.concurrent.TimeUnit
import kotlin.math.log
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes
+import kotlin.time.Duration.Companion.seconds
-class TrackScheduler(private val guild: Guild, private val link: Link) {
+class TrackScheduler(private val guild: Guild, val link: Link) {
companion object {
private val logger = LoggerFactory.getLogger(Companion::class.java)
private val audioManager = RobertifyAudioManager
+ private var EVENTS_SUBSCRIBED = false
}
private val requesters = ArrayList()
private var lastSentMsg: Message? = null
val disconnectManager = GuildDisconnectManager(guild)
-
val unannouncedTracks = emptyList().toMutableList()
- val player: Player
- get() = link.player
val queueHandler = QueueHandler()
+ val player: LavalinkPlayer? = link.getPlayer().block()
var announcementChannel: GuildMessageChannel? = null
- suspend fun queue(track: Track) {
- when {
- player.playingTrack != null -> queueHandler.add(track)
- else -> player.playTrack(track)
- }
+ private fun usePlayer(playerCallback: (LavalinkPlayer) -> Unit) {
+ link.getPlayer().subscribe(playerCallback)
}
- suspend fun queue(tracks: Collection