From ee07ed8afe78bcb50fd0f559b1c28e0dc183daa8 Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Wed, 16 Mar 2016 22:47:53 -0500 Subject: [PATCH] Only return valid existing voice connections --- wsapi.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wsapi.go b/wsapi.go index 94edb1d..1e8bb36 100644 --- a/wsapi.go +++ b/wsapi.go @@ -338,13 +338,13 @@ type voiceChannelJoinOp struct { // deaf : If true, you will be set to deafened upon joining. func (s *Session) ChannelVoiceJoin(gID, cID string, mute, deaf bool) (voice *VoiceConnection, err error) { - // If a voice connection alreadyy exists for this guild then + // If a voice connection already exists for this guild then // return that connection. If the channel differs, also change channels. - // TODO: check if the voice connection is really valid or just a shell - // because we might want to allow setting variables prior to getting here - // like debug, and other things. var ok bool - if voice, ok = s.VoiceConnections[gID]; ok { + if voice, ok = s.VoiceConnections[gID]; ok && voice.GuildID != "" { + //TODO: consider a better variable than GuildID in the above check + // to verify if this connection is valid or not. + if voice.ChannelID != cID { err = voice.ChangeChannel(cID) }