From 7d112b562e5ef9c64a703a475173e90c9a7d1ab0 Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Mon, 8 Feb 2016 10:08:24 -0800 Subject: [PATCH] Mirror the Voice guard. --- wsapi.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/wsapi.go b/wsapi.go index c0b6e33..f2d055c 100644 --- a/wsapi.go +++ b/wsapi.go @@ -321,7 +321,9 @@ func (s *Session) event(messageType int, message []byte) { } var st *VoiceServerUpdate if err = unmarshalEvent(e, &st); err == nil { - s.onVoiceServerUpdate(st) + if s.Voice != nil { + s.onVoiceServerUpdate(st) + } if s.OnVoiceServerUpdate != nil { s.OnVoiceServerUpdate(s, st) } @@ -335,7 +337,9 @@ func (s *Session) event(messageType int, message []byte) { } var st *VoiceState if err = unmarshalEvent(e, &st); err == nil { - s.onVoiceStateUpdate(st) + if s.Voice != nil { + s.onVoiceStateUpdate(st) + } if s.OnVoiceStateUpdate != nil { s.OnVoiceStateUpdate(s, st) } @@ -789,11 +793,6 @@ func (s *Session) onVoiceStateUpdate(st *VoiceState) { // connection and should happen after the VOICE_STATE event. func (s *Session) onVoiceServerUpdate(st *VoiceServerUpdate) { - // This shouldn't ever be the case, I don't think. - if s.Voice == nil { - return - } - // Store values for later use s.Voice.token = st.Token s.Voice.endpoint = st.Endpoint