Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing fields in Channel struct #366

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions discord/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ type Channel struct {
// DefaultReactionEmoji is the emoji to show in the add reaction button on a
// thread in a GuildForum channel
DefaultReactionEmoji *ForumReaction `json:"default_reaction_emoji,omitempty"`
// DefaultThreadRateLimitPerUser is the initial rate_limit_per_user 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,omitempty"`
// DefaultSoftOrder is the default sort order type used to order posts in GUILD_FORUM channels. Defaults to null, which indicates a preferred sort order hasn't been set by a channel admin.
DefaultSoftOrder *SortOrderType `json:"default_sort_order,omitempty"`
// DefaultForumLayout is the default forum layout view used to display posts in GUILD_FORUM channels. Defaults to 0, which indicates a layout view has not been set by a channel admin.
DefaultForumLayout ForumLayoutType `json:"default_forum_layout,omitempty"`
}

func (ch *Channel) UnmarshalJSON(data []byte) error {
Expand Down Expand Up @@ -340,3 +346,25 @@ type ForumReaction struct {
// Only one of EmojiID and EmojiName can be set
EmojiName option.String `json:"emoji_name"`
}

// https://discord.com/developers/docs/resources/channel#channel-object-sort-order-types
type SortOrderType uint8

const (
// Sort forum posts by activity.
SortOrderTypeLatestActivity SortOrderType = iota
// Sort forum posts by creation time (from most recent to oldest)
SoftOrderTypeCreationDate
)

// https://discord.com/developers/docs/resources/channel#channel-object-forum-layout-types
type ForumLayoutType uint8

const (
// No default has been set for forum channel.
ForumLayoutTypeNotSet ForumLayoutType = iota
// Display posts as a list.
ForumLayoutTypeListView
// Display posts as a collection of tiles.
ForumLayoutTypeGalleryView
)