Fix crash on user disconnect when no song is playing
This commit is contained in:
parent
7ea9a89fa5
commit
32d6d63f9f
2
main.go
2
main.go
|
@ -77,6 +77,7 @@ func (dj *mumbledj) OnTextMessage(e *gumble.TextMessageEvent) {
|
||||||
// the current status of the users on the server.
|
// the current status of the users on the server.
|
||||||
func (dj *mumbledj) OnUserChange(e *gumble.UserChangeEvent) {
|
func (dj *mumbledj) OnUserChange(e *gumble.UserChangeEvent) {
|
||||||
if e.Type.Has(gumble.UserChangeDisconnected) {
|
if e.Type.Has(gumble.UserChangeDisconnected) {
|
||||||
|
if dj.audioStream.IsPlaying() {
|
||||||
if dj.queue.CurrentItem().ItemType() == "playlist" {
|
if dj.queue.CurrentItem().ItemType() == "playlist" {
|
||||||
dj.queue.CurrentItem().(*Playlist).RemoveSkip(e.User.Name())
|
dj.queue.CurrentItem().(*Playlist).RemoveSkip(e.User.Name())
|
||||||
dj.queue.CurrentItem().(*Playlist).songs.CurrentItem().(*Song).RemoveSkip(e.User.Name())
|
dj.queue.CurrentItem().(*Playlist).songs.CurrentItem().(*Song).RemoveSkip(e.User.Name())
|
||||||
|
@ -84,6 +85,7 @@ func (dj *mumbledj) OnUserChange(e *gumble.UserChangeEvent) {
|
||||||
dj.queue.CurrentItem().(*Song).RemoveSkip(e.User.Name())
|
dj.queue.CurrentItem().(*Song).RemoveSkip(e.User.Name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if username has the permissions to execute a command. Permissions are specified in
|
// Checks if username has the permissions to execute a command. Permissions are specified in
|
||||||
|
|
Reference in a new issue