From 605bd7f29e8e1d02d4b52b44913e428642167316 Mon Sep 17 00:00:00 2001 From: Stein Ivar Berghei Date: Thu, 26 Oct 2023 22:50:02 +0200 Subject: [PATCH] Re-add ShufflePlaylist --- events.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/events.go b/events.go index 69ca6ac..97660ff 100644 --- a/events.go +++ b/events.go @@ -6,6 +6,7 @@ import ( discordspeaker "dndmusicbot/speaker" "encoding/json" "log" + "math/rand" "net/url" "os" "strconv" @@ -528,16 +529,18 @@ func (app *App) loadPlaylist(payload ...interface{}) { } list, err := ytdl_client.GetPlaylist(pl.Url) - if err != nil { log.Println("Error getting playlist info,", id) return } + rand.Shuffle(len(list.Videos), func(i, j int) { list.Videos[i], list.Videos[j] = list.Videos[j], list.Videos[i] }) + app.plmutex.Lock() if app.plcancel != nil { app.plcancel() } + app.mpd.Stop() app.mpd.Clear() app.plmutex.Unlock()