fix: Bot now leaves the channel, when the last song in the queue is finished playing

Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
limited_dev 2023-05-15 22:29:33 +02:00
parent f1454af395
commit ef130a1510
3 changed files with 9 additions and 5 deletions

View file

@ -100,7 +100,7 @@ class SkipButton : Button("btn.music.skip") {
val gts = MusicManager.getGuildTrackScheduler(guild.asGuild(), player)
if (!gts.isEmpty()) {
track = gts.getHead().toTrack()
gts.playNext()
gts.playNext(link)
response.respond {
this.embeds = mutableListOf(
MessageUtil.getEmbedWithImage(

View file

@ -85,7 +85,7 @@ class SkipExtension : Extension() {
val gts = MusicManager.getGuildTrackScheduler(this.guild!!.asGuild(), player)
if (!gts.isEmpty()) {
track = gts.getHead().toTrack()
gts.playNext()
gts.playNext(link)
} else {
player.stopTrack()
}

View file

@ -19,6 +19,7 @@
package de.limited_dev.botendo.extensions.music.components
import de.limited_dev.botendo.Bot
import de.limited_dev.botendo.util.Logger
import dev.schlaubi.lavakord.audio.*
import dev.schlaubi.lavakord.audio.player.Player
@ -41,11 +42,14 @@ class GuildTrackScheduler(val pl: Player) {
}
}
suspend fun playNext() {
suspend fun playNext(link: Link) {
if (!queue.isEmpty())
this.pl.playTrack(queue.poll())
else
else {
this.pl.stopTrack()
link.destroy()
clear()
}
}
private suspend fun play(tr: PartialTrack) {
@ -80,7 +84,7 @@ class GuildTrackScheduler(val pl: Player) {
return
}
Logger.out("Track has ended; Playing next...")
playNext()
playNext(Bot.lava.getLink(e.guildId))
}
}