forked from pothtonswer/discordmuffin
Added support for USER_SETTINGS_UPDATE websocket event, closes #11
This commit is contained in:
parent
57a5245657
commit
6991af8500
2 changed files with 13 additions and 0 deletions
|
@ -53,6 +53,7 @@ type Session struct {
|
|||
OnGuildRoleUpdate func(*Session, GuildRole)
|
||||
OnGuildRoleDelete func(*Session, GuildRoleDelete)
|
||||
OnGuildIntegrationsUpdate func(*Session, GuildIntegrationsUpdate)
|
||||
OnUserSettingsUpdate func(*Session, map[string]interface{}) // TODO: Find better way?
|
||||
|
||||
// Exposed but should not be modified by User.
|
||||
SessionID string // from websocket READY packet
|
||||
|
|
12
wsapi.go
12
wsapi.go
|
@ -406,6 +406,18 @@ func (s *Session) event(messageType int, message []byte) (err error) {
|
|||
s.OnGuildIntegrationsUpdate(s, st)
|
||||
return
|
||||
}
|
||||
|
||||
case "USER_SETTINGS_UPDATE":
|
||||
if s.OnUserSettingsUpdate != nil {
|
||||
var st map[string]interface{}
|
||||
if err := json.Unmarshal(e.RawData, &st); err != nil {
|
||||
fmt.Println(e.Type, err)
|
||||
printJSON(e.RawData) // TODO: Better error logginEventg
|
||||
return err
|
||||
}
|
||||
s.OnUserSettingsUpdate(s, st)
|
||||
return
|
||||
}
|
||||
default:
|
||||
fmt.Println("UNKNOWN EVENT: ", e.Type)
|
||||
// TODO learn the log package
|
||||
|
|
Loading…
Reference in a new issue