1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-10-02 07:18:49 +00:00

discord: Fix faulty marshal of Channel.RTCRegionID (#210)

This commit is contained in:
Maximilian von Lindern 2021-05-30 23:14:41 +02:00 committed by GitHub
parent 428ef4ac70
commit c45096c9fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()