Handle nil errors and default handler properly.
This commit is contained in:
parent
40b969d7c3
commit
7858f999b1
1 changed files with 12 additions and 4 deletions
16
wsapi.go
16
wsapi.go
|
@ -319,16 +319,24 @@ func (s *Session) event(messageType int, message []byte) {
|
|||
var st *VoiceServerUpdate
|
||||
if err = unmarshalEvent(e, &st); err == nil {
|
||||
s.onVoiceServerUpdate(st)
|
||||
s.OnVoiceServerUpdate(s, st)
|
||||
if s.OnVoiceServerUpdate != nil {
|
||||
s.OnVoiceServerUpdate(s, st)
|
||||
}
|
||||
}
|
||||
if s.OnVoiceServerUpdate != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
case "VOICE_STATE_UPDATE":
|
||||
var st *VoiceState
|
||||
if err = unmarshalEvent(e, &st); err == nil {
|
||||
s.onVoiceStateUpdate(st)
|
||||
s.OnVoiceStateUpdate(s, st)
|
||||
if s.OnVoiceStateUpdate != nil {
|
||||
s.OnVoiceStateUpdate(s, st)
|
||||
}
|
||||
}
|
||||
if s.OnVoiceStateUpdate != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
case "USER_UPDATE":
|
||||
if s.OnUserUpdate != nil {
|
||||
var st *User
|
||||
|
|
Loading…
Reference in a new issue