From 32d6d63f9f04c8ab0db8d8e59d10a2bc8454f212 Mon Sep 17 00:00:00 2001 From: Matthieu Grieger Date: Sun, 25 Jan 2015 14:04:47 -0800 Subject: [PATCH] Fix crash on user disconnect when no song is playing --- main.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index e48a0ba..fac8e95 100644 --- a/main.go +++ b/main.go @@ -77,11 +77,13 @@ func (dj *mumbledj) OnTextMessage(e *gumble.TextMessageEvent) { // the current status of the users on the server. func (dj *mumbledj) OnUserChange(e *gumble.UserChangeEvent) { if e.Type.Has(gumble.UserChangeDisconnected) { - if dj.queue.CurrentItem().ItemType() == "playlist" { - dj.queue.CurrentItem().(*Playlist).RemoveSkip(e.User.Name()) - dj.queue.CurrentItem().(*Playlist).songs.CurrentItem().(*Song).RemoveSkip(e.User.Name()) - } else { - dj.queue.CurrentItem().(*Song).RemoveSkip(e.User.Name()) + if dj.audioStream.IsPlaying() { + if dj.queue.CurrentItem().ItemType() == "playlist" { + dj.queue.CurrentItem().(*Playlist).RemoveSkip(e.User.Name()) + dj.queue.CurrentItem().(*Playlist).songs.CurrentItem().(*Song).RemoveSkip(e.User.Name()) + } else { + dj.queue.CurrentItem().(*Song).RemoveSkip(e.User.Name()) + } } } }