|
@@ -440,38 +440,34 @@ func (s *Session) ChannelVoiceJoin(gID, cID string, mute, deaf bool) (voice *Voi
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if voice == nil {
|
|
|
- voice = &VoiceConnection{}
|
|
|
- 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}}
|
|
|
s.wsMutex.Lock()
|
|
|
err = s.wsConn.WriteJSON(data)
|
|
|
s.wsMutex.Unlock()
|
|
|
if err != nil {
|
|
|
- s.log(LogInformational, "Deleting VoiceConnection %s", gID)
|
|
|
- delete(s.VoiceConnections, gID)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// doesn't exactly work perfect yet.. TODO
|
|
|
err = voice.waitUntilConnected()
|
|
|
if err != nil {
|
|
|
- s.log(LogWarning, "error waiting for voice connecting, %s", err)
|
|
|
+ s.log(LogWarning, "error waiting for voice to connect, %s", err)
|
|
|
voice.Close()
|
|
|
- s.log(LogInformational, "Deleting VoiceConnection %s", gID)
|
|
|
- delete(s.VoiceConnections, gID)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if voice == nil {
|
|
|
+ voice = &VoiceConnection{}
|
|
|
+ s.VoiceConnections[gID] = voice
|
|
|
+ }
|
|
|
+
|
|
|
+ voice.GuildID = gID
|
|
|
+ voice.ChannelID = cID
|
|
|
+ voice.deaf = deaf
|
|
|
+ voice.mute = mute
|
|
|
+ voice.session = s
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -536,7 +532,7 @@ func (s *Session) onVoiceServerUpdate(se *Session, st *VoiceServerUpdate) {
|
|
|
// Open a conenction to the voice server
|
|
|
err := voice.open()
|
|
|
if err != nil {
|
|
|
- s.log(LogError, "onVoiceServerUpdate voice.open, ", err)
|
|
|
+ s.log(LogError, "onVoiceServerUpdate voice.open, %s", err)
|
|
|
}
|
|
|
}
|
|
|
|