From c45096c9fad187c5107466e1e42877998ab15d44 Mon Sep 17 00:00:00 2001 From: Maximilian von Lindern Date: Sun, 30 May 2021 23:14:41 +0200 Subject: [PATCH] discord: Fix faulty marshal of Channel.RTCRegionID (#210) --- discord/channel.go | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/discord/channel.go b/discord/channel.go index 3dbf185..3c407ee 100644 --- a/discord/channel.go +++ b/discord/channel.go @@ -63,11 +63,7 @@ type Channel struct { // LastPinTime is when the last pinned message was pinned. LastPinTime Timestamp `json:"last_pin_timestamp,omitempty"` - // RTCRegionID is the voice region id for the voice channel. If set to - // null, the voice region is determined automatically. - // - // If RTCRegionID is an empty string, the region is automatically - // determined. + // RTCRegionID is the voice region id for the voice channel. RTCRegionID string `json:"rtc_region,omitempty"` // VideoQualityMode is the camera video quality mode of the voice channel. VideoQualityMode VideoQualityMode `json:"video_quality_mode,omitempty"` @@ -93,27 +89,6 @@ func (ch *Channel) UnmarshalJSON(data []byte) error { return nil } -func (ch Channel) MarshalJSON() ([]byte, error) { - type RawChannel Channel - - if ch.RTCRegionID != "" { - return json.Marshal(RawChannel(ch)) - } - - marshalChannel := struct { - RawChannel - // Remove the ",omitempty" flag, forcing RTCRegionID to be marshalled - // as JSON null. See the doc of Channel.RTCRegionID for more - // information. - RTCRegionID *string `json:"rtc_region"` - }{ - RawChannel: RawChannel(ch), - RTCRegionID: nil, - } - - return json.Marshal(marshalChannel) -} - // CreatedAt returns a time object representing when the channel was created. func (ch Channel) CreatedAt() time.Time { return ch.ID.Time()