Fixed panic when attempting to play empty queue
This commit is contained in:
parent
38be691913
commit
2b9394a371
|
@ -210,7 +210,7 @@ func add(user *gumble.User, username, url string) {
|
||||||
oldLength := dj.queue.Len()
|
oldLength := dj.queue.Len()
|
||||||
if newPlaylist, err := NewPlaylist(username, shortUrl); err == nil {
|
if newPlaylist, err := NewPlaylist(username, shortUrl); err == nil {
|
||||||
dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_ADDED_HTML, username, newPlaylist.title), false)
|
dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_ADDED_HTML, username, newPlaylist.title), false)
|
||||||
if oldLength == 0 && !dj.audioStream.IsPlaying() {
|
if oldLength == 0 && dj.queue.Len() != 0 && !dj.audioStream.IsPlaying() {
|
||||||
if err := dj.queue.CurrentSong().Download(); err == nil {
|
if err := dj.queue.CurrentSong().Download(); err == nil {
|
||||||
dj.queue.CurrentSong().Play()
|
dj.queue.CurrentSong().Play()
|
||||||
} else {
|
} else {
|
||||||
|
|
Reference in a new issue