mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-02-11 05:52:58 +00:00
discord: Fix faulty marshal of Channel.RTCRegionID (#210)
This commit is contained in:
parent
428ef4ac70
commit
c45096c9fa
|
@ -63,11 +63,7 @@ type Channel struct {
|
||||||
// LastPinTime is when the last pinned message was pinned.
|
// LastPinTime is when the last pinned message was pinned.
|
||||||
LastPinTime Timestamp `json:"last_pin_timestamp,omitempty"`
|
LastPinTime Timestamp `json:"last_pin_timestamp,omitempty"`
|
||||||
|
|
||||||
// RTCRegionID is the voice region id for the voice channel. If set to
|
// RTCRegionID is the voice region id for the voice channel.
|
||||||
// null, the voice region is determined automatically.
|
|
||||||
//
|
|
||||||
// If RTCRegionID is an empty string, the region is automatically
|
|
||||||
// determined.
|
|
||||||
RTCRegionID string `json:"rtc_region,omitempty"`
|
RTCRegionID string `json:"rtc_region,omitempty"`
|
||||||
// VideoQualityMode is the camera video quality mode of the voice channel.
|
// VideoQualityMode is the camera video quality mode of the voice channel.
|
||||||
VideoQualityMode VideoQualityMode `json:"video_quality_mode,omitempty"`
|
VideoQualityMode VideoQualityMode `json:"video_quality_mode,omitempty"`
|
||||||
|
@ -93,27 +89,6 @@ func (ch *Channel) UnmarshalJSON(data []byte) error {
|
||||||
return nil
|
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.
|
// CreatedAt returns a time object representing when the channel was created.
|
||||||
func (ch Channel) CreatedAt() time.Time {
|
func (ch Channel) CreatedAt() time.Time {
|
||||||
return ch.ID.Time()
|
return ch.ID.Time()
|
||||||
|
|
Loading…
Reference in a new issue