Skip to content

Commit

Permalink
add event umarshaler
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 committed Aug 24, 2024
1 parent df95c4b commit 843e2b9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
23 changes: 22 additions & 1 deletion gateway/gateway_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,31 @@ type EventVoiceChannelEffectSend struct {
Emoji *discord.Emoji `json:"emoji"`
AnimationType *discord.VoiceChannelEffectAnimationType `json:"animation_type,omitempty"`
AnimationID *int `json:"animation_id,omitempty"`
SoundID *int64 `json:"sound_id,string"`
SoundID *int64 `json:"-"`
SoundVolume *float64 `json:"sound_volume,omitempty"`
}

func (e *EventVoiceChannelEffectSend) UnmarshalJSON(data []byte) error {
type eventVoiceChannelEffectSend EventVoiceChannelEffectSend
var v struct {
SoundID *json.Number `json:"sound_id"`
eventVoiceChannelEffectSend
}
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*e = EventVoiceChannelEffectSend(v.eventVoiceChannelEffectSend)
if v.SoundID == nil {
return nil
}
i, err := v.SoundID.Int64()
if err != nil {
return err
}
e.SoundID = &i
return nil
}

func (EventVoiceChannelEffectSend) messageData() {}
func (EventVoiceChannelEffectSend) eventData() {}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/disgoorg/disgo
go 1.21

require (
github.com/disgoorg/json v1.1.0
github.com/disgoorg/json v1.2.0
github.com/disgoorg/snowflake/v2 v2.0.3
github.com/gorilla/websocket v1.5.3
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/disgoorg/json v1.1.0 h1:7xigHvomlVA9PQw9bMGO02PHGJJPqvX5AnwlYg/Tnys=
github.com/disgoorg/json v1.1.0/go.mod h1:BHDwdde0rpQFDVsRLKhma6Y7fTbQKub/zdGO5O9NqqA=
github.com/disgoorg/json v1.2.0 h1:6e/j4BCfSHIvucG1cd7tJPAOp1RgnnMFSqkvZUtEd1Y=
github.com/disgoorg/json v1.2.0/go.mod h1:BHDwdde0rpQFDVsRLKhma6Y7fTbQKub/zdGO5O9NqqA=
github.com/disgoorg/snowflake/v2 v2.0.3 h1:3B+PpFjr7j4ad7oeJu4RlQ+nYOTadsKapJIzgvSI2Ro=
github.com/disgoorg/snowflake/v2 v2.0.3/go.mod h1:W6r7NUA7DwfZLwr00km6G4UnZ0zcoLBRufhkFWgAc4c=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
Expand Down

0 comments on commit 843e2b9

Please sign in to comment.