Remove code duplication in ChannelVoiceJoin (#611)

This commit is contained in:
robbix1206 2018-11-06 02:37:18 +01:00 committed by Chris Rhodes
parent e184c57068
commit aca3f3898c

View file

@ -615,11 +615,7 @@ func (s *Session) ChannelVoiceJoin(gID, cID string, mute, deaf bool) (voice *Voi
voice.session = s
voice.Unlock()
// Send the request to Discord that we want to join the voice channel
data := voiceChannelJoinOp{4, voiceChannelJoinData{&gID, &cID, mute, deaf}}
s.wsMutex.Lock()
err = s.wsConn.WriteJSON(data)
s.wsMutex.Unlock()
err = s.ChannelVoiceJoinManual(gID, cID, mute, deaf)
if err != nil {
return
}
@ -652,10 +648,6 @@ func (s *Session) ChannelVoiceJoinManual(gID, cID string, mute, deaf bool) (err
s.wsMutex.Lock()
err = s.wsConn.WriteJSON(data)
s.wsMutex.Unlock()
if err != nil {
return
}
return
}