Add Forum settings to Channel struct (#1306)

* Add DefaultRateLimitPerUser DefaultSortOrder DefaultForumLayout to Channel struct

* Add prefix

* Add prefix

* Fix typo

* Fix field name typo

* Add to ChannelEdit struct

* Fix order and name

* Fix name

* Apply suggestions from code review

Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>

* feat: cosmetic changes

Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>
This commit is contained in:
ikafly144 2023-01-04 01:19:08 +09:00 committed by GitHub
parent 2daab506b2
commit ae8894be67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -302,6 +302,28 @@ const (
ChannelFlagRequireTag ChannelFlags = 1 << 4 ChannelFlagRequireTag ChannelFlags = 1 << 4
) )
// ForumSortOrderType represents sort order of a forum channel.
type ForumSortOrderType int
const (
// ForumSortOrderLatestActivity sorts posts by activity.
ForumSortOrderLatestActivity ForumSortOrderType = 0
// ForumSortOrderCreationDate sorts posts by creation time (from most recent to oldest).
ForumSortOrderCreationDate ForumSortOrderType = 1
)
// ForumLayout represents layout of a forum channel.
type ForumLayout int
const (
// ForumLayoutNotSet represents no default layout.
ForumLayoutNotSet ForumLayout = 0
// ForumLayoutListView displays forum posts as a list.
ForumLayoutListView ForumLayout = 1
// ForumLayoutGalleryView displays forum posts as a collection of tiles.
ForumLayoutGalleryView ForumLayout = 2
)
// A Channel holds all data related to an individual Discord channel. // A Channel holds all data related to an individual Discord channel.
type Channel struct { type Channel struct {
// The ID of the channel. // The ID of the channel.
@ -390,6 +412,18 @@ type Channel struct {
// Emoji to use as the default reaction to a forum post. // Emoji to use as the default reaction to a forum post.
DefaultReactionEmoji ForumDefaultReaction `json:"default_reaction_emoji"` DefaultReactionEmoji ForumDefaultReaction `json:"default_reaction_emoji"`
// The initial RateLimitPerUser to set on newly created threads in a channel.
// This field is copied to the thread at creation time and does not live update.
DefaultThreadRateLimitPerUser int `json:"default_thread_rate_limit_per_user"`
// The default sort order type used to order posts in forum channels.
// Defaults to null, which indicates a preferred sort order hasn't been set by a channel admin.
DefaultSortOrder *ForumSortOrderType `json:"default_sort_order"`
// The default forum layout view used to display posts in forum channels.
// Defaults to ForumLayoutNotSet, which indicates a layout view has not been set by a channel admin.
DefaultForumLayout ForumLayout `json:"default_forum_layout"`
} }
// Mention returns a string which mentions the channel // Mention returns a string which mentions the channel
@ -414,6 +448,7 @@ type ChannelEdit struct {
ParentID string `json:"parent_id,omitempty"` ParentID string `json:"parent_id,omitempty"`
RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"` RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"`
Flags *ChannelFlags `json:"flags,omitempty"` Flags *ChannelFlags `json:"flags,omitempty"`
DefaultThreadRateLimitPerUser *int `json:"default_thread_rate_limit_per_user,omitempty"`
// NOTE: threads only // NOTE: threads only
@ -426,6 +461,8 @@ type ChannelEdit struct {
AvailableTags *[]ForumTag `json:"available_tags,omitempty"` AvailableTags *[]ForumTag `json:"available_tags,omitempty"`
DefaultReactionEmoji *ForumDefaultReaction `json:"default_reaction_emoji,omitempty"` DefaultReactionEmoji *ForumDefaultReaction `json:"default_reaction_emoji,omitempty"`
DefaultSortOrder *ForumSortOrderType `json:"default_sort_order,omitempty"` // TODO: null
DefaultForumLayout *ForumLayout `json:"default_forum_layout,omitempty"`
// NOTE: forum threads only // NOTE: forum threads only
AppliedTags *[]string `json:"applied_tags,omitempty"` AppliedTags *[]string `json:"applied_tags,omitempty"`