feat: leave vc, if there is no song next up and the current one failed to load
This commit is contained in:
parent
ae507dc4aa
commit
8b6b7dc5d5
1 changed files with 12 additions and 0 deletions
|
@ -36,6 +36,10 @@ import net.moonleay.botendo.util.*
|
||||||
object MusicManager {
|
object MusicManager {
|
||||||
private var musicManagerMap: MutableMap<Snowflake, GuildTrackScheduler> = mutableMapOf()
|
private var musicManagerMap: MutableMap<Snowflake, GuildTrackScheduler> = mutableMapOf()
|
||||||
|
|
||||||
|
fun getMusicManager(guild: Guild): GuildTrackScheduler? {
|
||||||
|
return musicManagerMap[guild.id]
|
||||||
|
}
|
||||||
|
|
||||||
fun getGuildTrackScheduler(guild: Guild, player: Player): GuildTrackScheduler {
|
fun getGuildTrackScheduler(guild: Guild, player: Player): GuildTrackScheduler {
|
||||||
return musicManagerMap.computeIfAbsent(guild.id) {
|
return musicManagerMap.computeIfAbsent(guild.id) {
|
||||||
GuildTrackScheduler(player)
|
GuildTrackScheduler(player)
|
||||||
|
@ -181,6 +185,10 @@ object MusicManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
is LoadResult.NoMatches -> {
|
is LoadResult.NoMatches -> {
|
||||||
|
if(gts.isEmpty()) {
|
||||||
|
player.stopTrack()
|
||||||
|
link.destroy()
|
||||||
|
}
|
||||||
if (!silent)
|
if (!silent)
|
||||||
ctx.respond {
|
ctx.respond {
|
||||||
this.embed {
|
this.embed {
|
||||||
|
@ -194,6 +202,10 @@ object MusicManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is LoadResult.LoadFailed -> {
|
is LoadResult.LoadFailed -> {
|
||||||
|
if (gts.isEmpty()) {
|
||||||
|
player.stopTrack()
|
||||||
|
link.destroy()
|
||||||
|
}
|
||||||
if (!silent)
|
if (!silent)
|
||||||
ctx.respond {
|
ctx.respond {
|
||||||
this.embed {
|
this.embed {
|
||||||
|
|
Loading…
Reference in a new issue