diff --git a/event.go b/event.go index 1524f32..3a03f46 100644 --- a/event.go +++ b/event.go @@ -224,7 +224,7 @@ func (s *Session) onInterface(i interface{}) { case *VoiceStateUpdate: go s.onVoiceStateUpdate(t) } - err := s.State.onInterface(s, i) + err := s.State.OnInterface(s, i) if err != nil { s.log(LogDebug, "error dispatching internal event, %s", err) } diff --git a/restapi.go b/restapi.go index 0bcd2ba..ee563b9 100644 --- a/restapi.go +++ b/restapi.go @@ -1867,14 +1867,9 @@ func (s *Session) WebhookEditWithToken(webhookID, token, name, avatar string) (s // WebhookDelete deletes a webhook for a given ID // webhookID: The ID of a webhook. -func (s *Session) WebhookDelete(webhookID string) (st *Webhook, err error) { +func (s *Session) WebhookDelete(webhookID string) (err error) { - body, err := s.RequestWithBucketID("DELETE", EndpointWebhook(webhookID), nil, EndpointWebhooks) - if err != nil { - return - } - - err = unmarshal(body, &st) + _, err = s.RequestWithBucketID("DELETE", EndpointWebhook(webhookID), nil, EndpointWebhooks) return } diff --git a/state.go b/state.go index b545c53..7627796 100644 --- a/state.go +++ b/state.go @@ -783,7 +783,7 @@ func (s *State) onReady(se *Session, r *Ready) (err error) { } // onInterface handles all events related to states. -func (s *State) onInterface(se *Session, i interface{}) (err error) { +func (s *State) OnInterface(se *Session, i interface{}) (err error) { if s == nil { return ErrNilState } diff --git a/structs.go b/structs.go index e811e9e..5dde7aa 100644 --- a/structs.go +++ b/structs.go @@ -316,7 +316,7 @@ type Presence struct { type Game struct { Name string `json:"name"` Type int `json:"type"` - URL string `json:"url"` + URL string `json:"url,omitempty"` } // UnmarshalJSON unmarshals json to Game struct diff --git a/voice.go b/voice.go index cd0f168..218753a 100644 --- a/voice.go +++ b/voice.go @@ -15,7 +15,6 @@ import ( "fmt" "log" "net" - "runtime" "strconv" "strings" "sync" @@ -660,8 +659,6 @@ func (v *VoiceConnection) opusSender(udpConn *net.UDPConn, close <-chan struct{} return } - runtime.LockOSThread() - // VoiceConnection is now ready to receive audio packets // TODO: this needs reviewed as I think there must be a better way. v.Lock() @@ -800,7 +797,7 @@ func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct } // For now, skip anything except audio. - if rlen < 12 || recvbuf[0] != 0x80 { + if rlen < 12 || (recvbuf[0] != 0x80 && recvbuf[0] != 0x90) { continue } @@ -814,6 +811,11 @@ func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct copy(nonce[:], recvbuf[0:12]) p.Opus, _ = secretbox.Open(nil, recvbuf[12:rlen], &nonce, &v.op4.SecretKey) + if len(p.Opus) > 8 && recvbuf[0] == 0x90 { + // Extension bit is set, first 8 bytes is the extended header + p.Opus = p.Opus[8:] + } + if c != nil { select { case c <- &p: diff --git a/wsapi.go b/wsapi.go index baec234..ab37b5a 100644 --- a/wsapi.go +++ b/wsapi.go @@ -250,8 +250,10 @@ func (s *Session) heartbeat(wsConn *websocket.Conn, listening <-chan interface{} } type updateStatusData struct { - IdleSince *int `json:"idle_since"` - Game *Game `json:"game"` + IdleSince *int `json:"since"` + Game *Game `json:"game"` + AFK bool `json:"afk"` + Status string `json:"status"` } type updateStatusOp struct { @@ -274,7 +276,10 @@ func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err return ErrWSNotFound } - var usd updateStatusData + usd := updateStatusData{ + Status: "online", + } + if idle > 0 { usd.IdleSince = &idle }