From 7957f483ca35650cc3d051f94b3f2b69f33b2f38 Mon Sep 17 00:00:00 2001 From: sebm253 <42180891+sebm253@users.noreply.github.com> Date: Wed, 21 Aug 2024 22:56:21 +0200 Subject: [PATCH 1/4] oh man --- gateway/gateway_events.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/gateway_events.go b/gateway/gateway_events.go index a6972697..45d1cf63 100644 --- a/gateway/gateway_events.go +++ b/gateway/gateway_events.go @@ -610,7 +610,7 @@ type EventVoiceChannelEffectSend struct { Emoji *discord.Emoji `json:"emoji"` AnimationType *discord.VoiceChannelEffectAnimationType `json:"animation_type,omitempty"` AnimationID *int `json:"animation_id,omitempty"` - SoundID *snowflake.ID `json:"sound_id,omitempty"` + SoundID *snowflake.ID `json:"sound_id,string"` SoundVolume *float64 `json:"sound_volume,omitempty"` } From 5d5e919289e1444f5c4545a7af698c49b68a543e Mon Sep 17 00:00:00 2001 From: sebm253 <42180891+sebm253@users.noreply.github.com> Date: Fri, 23 Aug 2024 21:38:47 +0200 Subject: [PATCH 2/4] Revert "oh man" This reverts commit 7957f483ca35650cc3d051f94b3f2b69f33b2f38. --- gateway/gateway_events.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/gateway_events.go b/gateway/gateway_events.go index 45d1cf63..a6972697 100644 --- a/gateway/gateway_events.go +++ b/gateway/gateway_events.go @@ -610,7 +610,7 @@ type EventVoiceChannelEffectSend struct { Emoji *discord.Emoji `json:"emoji"` AnimationType *discord.VoiceChannelEffectAnimationType `json:"animation_type,omitempty"` AnimationID *int `json:"animation_id,omitempty"` - SoundID *snowflake.ID `json:"sound_id,string"` + SoundID *snowflake.ID `json:"sound_id,omitempty"` SoundVolume *float64 `json:"sound_volume,omitempty"` } From df95c4b6b6e7d6a8378542b80209eb19a580047d Mon Sep 17 00:00:00 2001 From: sebm253 <42180891+sebm253@users.noreply.github.com> Date: Fri, 23 Aug 2024 21:44:28 +0200 Subject: [PATCH 3/4] change SoundID type to int64 with ,string --- gateway/gateway_events.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/gateway_events.go b/gateway/gateway_events.go index a6972697..dc897e5d 100644 --- a/gateway/gateway_events.go +++ b/gateway/gateway_events.go @@ -610,7 +610,7 @@ type EventVoiceChannelEffectSend struct { Emoji *discord.Emoji `json:"emoji"` AnimationType *discord.VoiceChannelEffectAnimationType `json:"animation_type,omitempty"` AnimationID *int `json:"animation_id,omitempty"` - SoundID *snowflake.ID `json:"sound_id,omitempty"` + SoundID *int64 `json:"sound_id,string"` SoundVolume *float64 `json:"sound_volume,omitempty"` } From 843e2b952a0cd438da2b032c38c8da6da1589bce Mon Sep 17 00:00:00 2001 From: sebm253 <42180891+sebm253@users.noreply.github.com> Date: Sat, 24 Aug 2024 21:20:33 +0200 Subject: [PATCH 4/4] add event umarshaler --- gateway/gateway_events.go | 23 ++++++++++++++++++++++- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/gateway/gateway_events.go b/gateway/gateway_events.go index dc897e5d..8afcee37 100644 --- a/gateway/gateway_events.go +++ b/gateway/gateway_events.go @@ -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() {} diff --git a/go.mod b/go.mod index b0052dca..22e68fb7 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 9d343049..4d38e69d 100644 --- a/go.sum +++ b/go.sum @@ -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=