forked from pothtonswer/discordmuffin
handle empty channel id in ChannelVoiceJoinManual (#672)
This commit is contained in:
parent
d19be02e42
commit
e405cbd54c
1 changed files with 9 additions and 2 deletions
11
wsapi.go
11
wsapi.go
|
@ -635,15 +635,22 @@ func (s *Session) ChannelVoiceJoin(gID, cID string, mute, deaf bool) (voice *Voi
|
||||||
// This should only be used when the VoiceServerUpdate will be intercepted and used elsewhere.
|
// This should only be used when the VoiceServerUpdate will be intercepted and used elsewhere.
|
||||||
//
|
//
|
||||||
// gID : Guild ID of the channel to join.
|
// gID : Guild ID of the channel to join.
|
||||||
// cID : Channel ID of the channel to join.
|
// cID : Channel ID of the channel to join, leave empty to disconnect.
|
||||||
// mute : If true, you will be set to muted upon joining.
|
// mute : If true, you will be set to muted upon joining.
|
||||||
// deaf : If true, you will be set to deafened upon joining.
|
// deaf : If true, you will be set to deafened upon joining.
|
||||||
func (s *Session) ChannelVoiceJoinManual(gID, cID string, mute, deaf bool) (err error) {
|
func (s *Session) ChannelVoiceJoinManual(gID, cID string, mute, deaf bool) (err error) {
|
||||||
|
|
||||||
s.log(LogInformational, "called")
|
s.log(LogInformational, "called")
|
||||||
|
|
||||||
|
var channelID *string
|
||||||
|
if cID == "" {
|
||||||
|
channelID = nil
|
||||||
|
} else {
|
||||||
|
channelID = &cID
|
||||||
|
}
|
||||||
|
|
||||||
// Send the request to Discord that we want to join the voice channel
|
// Send the request to Discord that we want to join the voice channel
|
||||||
data := voiceChannelJoinOp{4, voiceChannelJoinData{&gID, &cID, mute, deaf}}
|
data := voiceChannelJoinOp{4, voiceChannelJoinData{&gID, channelID, mute, deaf}}
|
||||||
s.wsMutex.Lock()
|
s.wsMutex.Lock()
|
||||||
err = s.wsConn.WriteJSON(data)
|
err = s.wsConn.WriteJSON(data)
|
||||||
s.wsMutex.Unlock()
|
s.wsMutex.Unlock()
|
||||||
|
|
Loading…
Reference in a new issue