feat: leave vc, if there is no song next up and the current one failed to load

This commit is contained in:
moonleay 2023-12-13 18:50:38 +01:00
parent ae507dc4aa
commit 8b6b7dc5d5
Signed by: moonleay
GPG key ID: 82667543CCD715FB

View file

@ -36,6 +36,10 @@ import net.moonleay.botendo.util.*
object MusicManager {
private var musicManagerMap: MutableMap<Snowflake, GuildTrackScheduler> = mutableMapOf()
fun getMusicManager(guild: Guild): GuildTrackScheduler? {
return musicManagerMap[guild.id]
}
fun getGuildTrackScheduler(guild: Guild, player: Player): GuildTrackScheduler {
return musicManagerMap.computeIfAbsent(guild.id) {
GuildTrackScheduler(player)
@ -181,6 +185,10 @@ object MusicManager {
}
is LoadResult.NoMatches -> {
if(gts.isEmpty()) {
player.stopTrack()
link.destroy()
}
if (!silent)
ctx.respond {
this.embed {
@ -194,6 +202,10 @@ object MusicManager {
}
}
is LoadResult.LoadFailed -> {
if (gts.isEmpty()) {
player.stopTrack()
link.destroy()
}
if (!silent)
ctx.respond {
this.embed {