From 9d42bf1cc67acc9534fd33cc4f3d2d4435310c0c Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Wed, 25 Nov 2015 08:31:26 -0600 Subject: [PATCH] Check that websocket exists before trying to send VoiceSpeaking --- voice.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/voice.go b/voice.go index 6fd8d02..282be7a 100644 --- a/voice.go +++ b/voice.go @@ -210,6 +210,12 @@ func (s *Session) VoiceCloseUDP() { func (s *Session) VoiceSpeaking() { + if s.VwsConn == nil { + // TODO return an error + fmt.Println("No Voice websocket.") + return + } + jsonb := []byte(`{"op":5,"d":{"speaking":true,"delay":0}}`) err := s.VwsConn.WriteMessage(websocket.TextMessage, jsonb) if err != nil {