Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Commit ae8894b

Browse files
Add Forum settings to Channel struct (bwmarrin#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 <[email protected]> * feat: cosmetic changes Co-authored-by: Fedor Lapshin <[email protected]>
1 parent 2daab50 commit ae8894b

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

structs.go

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,28 @@ const (
302302
ChannelFlagRequireTag ChannelFlags = 1 << 4
303303
)
304304

305+
// ForumSortOrderType represents sort order of a forum channel.
306+
type ForumSortOrderType int
307+
308+
const (
309+
// ForumSortOrderLatestActivity sorts posts by activity.
310+
ForumSortOrderLatestActivity ForumSortOrderType = 0
311+
// ForumSortOrderCreationDate sorts posts by creation time (from most recent to oldest).
312+
ForumSortOrderCreationDate ForumSortOrderType = 1
313+
)
314+
315+
// ForumLayout represents layout of a forum channel.
316+
type ForumLayout int
317+
318+
const (
319+
// ForumLayoutNotSet represents no default layout.
320+
ForumLayoutNotSet ForumLayout = 0
321+
// ForumLayoutListView displays forum posts as a list.
322+
ForumLayoutListView ForumLayout = 1
323+
// ForumLayoutGalleryView displays forum posts as a collection of tiles.
324+
ForumLayoutGalleryView ForumLayout = 2
325+
)
326+
305327
// A Channel holds all data related to an individual Discord channel.
306328
type Channel struct {
307329
// The ID of the channel.
@@ -390,6 +412,18 @@ type Channel struct {
390412

391413
// Emoji to use as the default reaction to a forum post.
392414
DefaultReactionEmoji ForumDefaultReaction `json:"default_reaction_emoji"`
415+
416+
// The initial RateLimitPerUser to set on newly created threads in a channel.
417+
// This field is copied to the thread at creation time and does not live update.
418+
DefaultThreadRateLimitPerUser int `json:"default_thread_rate_limit_per_user"`
419+
420+
// The default sort order type used to order posts in forum channels.
421+
// Defaults to null, which indicates a preferred sort order hasn't been set by a channel admin.
422+
DefaultSortOrder *ForumSortOrderType `json:"default_sort_order"`
423+
424+
// The default forum layout view used to display posts in forum channels.
425+
// Defaults to ForumLayoutNotSet, which indicates a layout view has not been set by a channel admin.
426+
DefaultForumLayout ForumLayout `json:"default_forum_layout"`
393427
}
394428

395429
// Mention returns a string which mentions the channel
@@ -404,16 +438,17 @@ func (c *Channel) IsThread() bool {
404438

405439
// A ChannelEdit holds Channel Field data for a channel edit.
406440
type ChannelEdit struct {
407-
Name string `json:"name,omitempty"`
408-
Topic string `json:"topic,omitempty"`
409-
NSFW *bool `json:"nsfw,omitempty"`
410-
Position int `json:"position"`
411-
Bitrate int `json:"bitrate,omitempty"`
412-
UserLimit int `json:"user_limit,omitempty"`
413-
PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
414-
ParentID string `json:"parent_id,omitempty"`
415-
RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"`
416-
Flags *ChannelFlags `json:"flags,omitempty"`
441+
Name string `json:"name,omitempty"`
442+
Topic string `json:"topic,omitempty"`
443+
NSFW *bool `json:"nsfw,omitempty"`
444+
Position int `json:"position"`
445+
Bitrate int `json:"bitrate,omitempty"`
446+
UserLimit int `json:"user_limit,omitempty"`
447+
PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
448+
ParentID string `json:"parent_id,omitempty"`
449+
RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"`
450+
Flags *ChannelFlags `json:"flags,omitempty"`
451+
DefaultThreadRateLimitPerUser *int `json:"default_thread_rate_limit_per_user,omitempty"`
417452

418453
// NOTE: threads only
419454

@@ -426,6 +461,8 @@ type ChannelEdit struct {
426461

427462
AvailableTags *[]ForumTag `json:"available_tags,omitempty"`
428463
DefaultReactionEmoji *ForumDefaultReaction `json:"default_reaction_emoji,omitempty"`
464+
DefaultSortOrder *ForumSortOrderType `json:"default_sort_order,omitempty"` // TODO: null
465+
DefaultForumLayout *ForumLayout `json:"default_forum_layout,omitempty"`
429466

430467
// NOTE: forum threads only
431468
AppliedTags *[]string `json:"applied_tags,omitempty"`

0 commit comments

Comments
 (0)