From eec0faa7b3010a517a18a62798516bcdda4447b3 Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Thu, 18 Feb 2016 21:42:23 -0600 Subject: [PATCH] Handle VOICE_SERVER_UPDATE better, closes #115 --- wsapi.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wsapi.go b/wsapi.go index 0060cc6..9ae33ce 100644 --- a/wsapi.go +++ b/wsapi.go @@ -466,6 +466,10 @@ func (s *Session) onVoiceServerUpdate(se *Session, st *VoiceServerUpdate) { s.Voice.endpoint = st.Endpoint s.Voice.guildID = st.GuildID + // If currently connected to voice ws/udp, then disconnect. + // Has no effect if not connected. + s.Voice.Close() + // We now have enough information to open a voice websocket conenction // so, that's what the next call does. err := s.Voice.Open()