From fa35b32b791471fdaa85e2d1d72efbc02da0a59d Mon Sep 17 00:00:00 2001 From: svenwiltink Date: Fri, 23 Sep 2022 09:00:04 +0200 Subject: [PATCH] discord: Add ChannelFlags (#345) * added ChannelFlags * Minor style fixes, comment additions Co-authored-by: diamondburned --- api/channel.go | 4 ++++ discord/channel.go | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/api/channel.go b/api/channel.go index 9858261..7e64503 100644 --- a/api/channel.go +++ b/api/channel.go @@ -28,6 +28,8 @@ type CreateChannelData struct { // // Channel Types: Text, News Topic string `json:"topic,omitempty"` + // Flags is a bitmask that contains if a thread is pinned for example + Flags discord.ChannelFlags `json:"flags,omitempty"` // VoiceBitrate is the bitrate (in bits) of the voice channel. // 8000 to 96000 (128000 for VIP servers) // @@ -157,6 +159,8 @@ type ModifyChannelData struct { // // Channel Types: Text, News Topic option.NullableString `json:"topic,omitempty"` + // Flags is a bitmask that contains if a thread is pinned for example + Flags *discord.ChannelFlags `json:"flags,omitempty"` // NSFW specifies whether the channel is nsfw. // // Channel Types: Text, News, Store diff --git a/discord/channel.go b/discord/channel.go index a9cf4e1..79bf400 100644 --- a/discord/channel.go +++ b/discord/channel.go @@ -9,6 +9,22 @@ import ( "github.com/diamondburned/arikawa/v3/utils/json/option" ) +// ChannelFlags are the channel flags combined as a bitfield. +type ChannelFlags uint64 + +const ( + _ ChannelFlags = 1 << iota + // PinnedThread means this thread is pinned to the top of its parent + // GuildForum channel. + PinnedThread + _ + _ + // ThreadRequireTag is whether a tag is required to be specified when + // creating a thread in a GuildForum channel. Tags are specified in the + // AppliedTags field. + ThreadRequireTag +) + // Channel represents a guild or DM channel within Discord. // // https://discord.com/developers/docs/resources/channel#channel-object @@ -46,6 +62,9 @@ type Channel struct { // VoiceUserLimit is the user limit of the voice channel. VoiceUserLimit uint `json:"user_limit,omitempty"` + // Flags is a bitmask that contains if a thread is pinned, for example. + Flags ChannelFlags `json:"flags,omitempty"` + // UserRateLimit is the amount of seconds a user has to wait before sending // another message (0-21600). Bots, as well as users with the permission // manage_messages or manage_channel, are unaffected.