From a00f64aa86ed4e4ebfbf39323afc19d83f52bd1e Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Thu, 12 May 2016 19:23:38 -0500 Subject: [PATCH] Don't stomp on VoiceConnection if exists already This allows you to enable voice debugging prior to joining a voice channel. --- wsapi.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/wsapi.go b/wsapi.go index c51a445..ebcab71 100644 --- a/wsapi.go +++ b/wsapi.go @@ -519,18 +519,16 @@ func (s *Session) ChannelVoiceJoin(gID, cID string, mute, deaf bool) (voice *Voi return } - // Create a new voice session - // TODO review what all these things are for.... - voice = &VoiceConnection{ - GuildID: gID, - ChannelID: cID, - deaf: deaf, - mute: mute, - session: s, + if voice == nil { + voice = &VoiceConnection{} + s.VoiceConnections[gID] = voice } - // Store voice in VoiceConnections map for this GuildID - s.VoiceConnections[gID] = voice + voice.GuildID = gID + voice.ChannelID = cID + voice.deaf = deaf + voice.mute = mute + voice.session = s // Send the request to Discord that we want to join the voice channel data := voiceChannelJoinOp{4, voiceChannelJoinData{&gID, &cID, mute, deaf}}