From b7421315eaafcf7cee55ccd5d1ba862695a37c02 Mon Sep 17 00:00:00 2001 From: Sven Wiltink Date: Wed, 21 Sep 2022 15:08:17 +0000 Subject: [PATCH] Add Tag and TagID for forum capabilities --- api/channel.go | 3 +++ discord/channel.go | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/api/channel.go b/api/channel.go index e892238..de09b53 100644 --- a/api/channel.go +++ b/api/channel.go @@ -210,6 +210,9 @@ type ModifyChannelData struct { Invitable option.Bool `json:"invitable,omitempty"` AuditLogReason `json:"-"` + + AvailableTags *[]discord.Tag `json:"available_tags,omitempty"` + AppliedTags *[]discord.TagID `json:"applied_tags,omitempty"` } // ModifyChannel updates a channel's settings. diff --git a/discord/channel.go b/discord/channel.go index 72f04be..8511de0 100644 --- a/discord/channel.go +++ b/discord/channel.go @@ -95,6 +95,9 @@ type Channel struct { // the channel, including overwrites, only included when part of the // resolved data received on a slash command interaction. SelfPermissions Permissions `json:"permissions,omitempty,string"` + + AvailableTags []Tag `json:"available_tags"` + AppliedTags []TagID `json:"applied_tags"` } func (ch *Channel) UnmarshalJSON(data []byte) error { @@ -290,3 +293,34 @@ type ThreadMember struct { // ThreadMemberFlags are the flags of a ThreadMember. // Currently, none are documented. type ThreadMemberFlags uint64 + +type TagID Snowflake + +// NullTagID gets encoded into a null. This is used for optional and nullable snowflake fields. +const NullTagID = TagID(NullSnowflake) + +func (s TagID) MarshalJSON() ([]byte, error) { return Snowflake(s).MarshalJSON() } +func (s *TagID) UnmarshalJSON(v []byte) error { return (*Snowflake)(s).UnmarshalJSON(v) } + +// String returns the ID, or nothing if the snowflake isn't valid. +func (s TagID) String() string { return Snowflake(s).String() } + +// IsValid returns whether or not the snowflake is valid. +func (s TagID) IsValid() bool { return Snowflake(s).IsValid() } + +// IsNull returns whether or not the snowflake is null. This method is rarely +// ever useful; most people should use IsValid instead. +func (s TagID) IsNull() bool { return Snowflake(s).IsNull() } + +func (s TagID) Time() time.Time { return Snowflake(s).Time() } +func (s TagID) Worker() uint8 { return Snowflake(s).Worker() } +func (s TagID) PID() uint8 { return Snowflake(s).PID() } +func (s TagID) Increment() uint16 { return Snowflake(s).Increment() } + +type Tag struct { + ID TagID `json:"id,omitempty"` + Name string `json:"name"` + EmojiID EmojiID `json:"emoji_id"` + EmojiName *string `json:"emoji_name` + Moderated bool `json:"moderated"` +}