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()