glyde/model/channel
Channels, threads and permission overwrites.
One flat record with a type_, not a sum type: twelve of the thirteen
types carry name, so a sum type would force a twelve-arm case to read it.
Only id and type_ are required, so an interaction’s partial channel
decodes through the same decoder as a full one.
Types
The body of GET /guilds/{id}/threads/active, which is every active thread
at once. Discord sends no has_more here, so there is no page to ask for.
pub type ActiveThreads {
ActiveThreads(
threads: List(Channel),
members: List(ThreadMember),
)
}
Constructors
-
ActiveThreads( threads: List(Channel), members: List(ThreadMember), )
A channel of any kind, threads included.
pub type Channel {
Channel(
id: id.Id(id.Channel),
type_: ChannelType,
guild_id: option.Option(id.Id(id.Guild)),
position: option.Option(Int),
permission_overwrites: option.Option(
List(PermissionOverwrite),
),
name: option.Option(String),
topic: option.Option(String),
nsfw: option.Option(Bool),
last_message_id: option.Option(id.Id(id.Message)),
bitrate: option.Option(Int),
user_limit: option.Option(Int),
rate_limit_per_user: option.Option(Int),
recipients: option.Option(List(user.User)),
icon: option.Option(String),
owner_id: option.Option(id.Id(id.User)),
application_id: option.Option(id.Id(id.Application)),
managed: option.Option(Bool),
parent_id: option.Option(id.Id(id.Channel)),
last_pin_timestamp: option.Option(String),
rtc_region: option.Option(String),
video_quality_mode: option.Option(VideoQualityMode),
message_count: option.Option(Int),
member_count: option.Option(Int),
thread_metadata: option.Option(ThreadMetadata),
member: option.Option(ThreadMember),
default_auto_archive_duration: option.Option(
ThreadAutoArchiveDuration,
),
permissions: option.Option(permissions.Permissions),
flags: option.Option(flags.Flags(ChannelFlag)),
total_message_sent: option.Option(Int),
default_thread_rate_limit_per_user: option.Option(Int),
newly_created: option.Option(Bool),
)
}
Constructors
-
Channel( id: id.Id(id.Channel), type_: ChannelType, guild_id: option.Option(id.Id(id.Guild)), position: option.Option(Int), permission_overwrites: option.Option(List(PermissionOverwrite)), name: option.Option(String), topic: option.Option(String), nsfw: option.Option(Bool), last_message_id: option.Option(id.Id(id.Message)), bitrate: option.Option(Int), user_limit: option.Option(Int), rate_limit_per_user: option.Option(Int), recipients: option.Option(List(user.User)), icon: option.Option(String), owner_id: option.Option(id.Id(id.User)), application_id: option.Option(id.Id(id.Application)), managed: option.Option(Bool), parent_id: option.Option(id.Id(id.Channel)), last_pin_timestamp: option.Option(String), rtc_region: option.Option(String), video_quality_mode: option.Option(VideoQualityMode), message_count: option.Option(Int), member_count: option.Option(Int), thread_metadata: option.Option(ThreadMetadata), member: option.Option(ThreadMember), default_auto_archive_duration: option.Option( ThreadAutoArchiveDuration, ), permissions: option.Option(permissions.Permissions), flags: option.Option(flags.Flags(ChannelFlag)), total_message_sent: option.Option(Int), default_thread_rate_limit_per_user: option.Option(Int), newly_created: option.Option(Bool), )Arguments
- last_message_id
-
May point at a deleted message.
- user_limit
-
0 means no limit.
- rate_limit_per_user
-
Slowmode in SECONDS, 0 to 21600. Also gates thread creation.
- rtc_region
-
Null means Discord picks the region.
- message_count
-
Threads only. Excludes the initial message, and stops at 50 on threads created before 2022-07-01.
- member_count
-
Threads only. STOPS COUNTING AT 50.
- member
-
The current user’s membership: only
flagsandjoin_timestamp. - default_auto_archive_duration
-
MINUTES.
- permissions
-
The invoking user’s computed permissions, on the partial channels in an interaction’s resolved data and nowhere else. The bot’s own are
app_permissionsonmodel/interaction.Interaction, a key of the interaction rather than of any channel in it. - flags
-
Noneon the shapes that drop the key, an interaction’s partial included. Defaulting it to 0 would let a cache merge clear flags nobody cleared, and an edit sends that back. - total_message_sent
-
Threads only. Unlike
message_countthis never decrements. - newly_created
-
THREAD_CREATE only: a new thread, not one the bot was added to.
pub type ChannelFlag {
Pinned
RequireTag
HideMediaDownloadOptions
IsSpoilerChannel
}
Constructors
-
PinnedA forum or media post pinned to the top of its parent.
-
RequireTagThe parent forum requires a tag on every post.
-
HideMediaDownloadOptions -
IsSpoilerChannelEvery attachment in the channel is treated as a spoiler.
pub type ChannelFlags =
flags.Flags(ChannelFlag)
Live values are 0 to 5, 10 to 13, 15 and 16. 14 is hub-only, and 6 to 9 were withdrawn but can still turn up in cached data.
pub type ChannelType {
GuildText
Dm
GuildVoice
GroupDm
GuildCategory
GuildAnnouncement
AnnouncementThread
PublicThread
PrivateThread
GuildStageVoice
GuildDirectory
GuildForum
GuildMedia
UnknownChannelType(Int)
}
Constructors
-
GuildText -
Dm -
GuildVoice -
GroupDm -
GuildCategory -
GuildAnnouncement -
AnnouncementThread -
PublicThread -
PrivateThread -
GuildStageVoice -
GuildDirectory -
GuildForum -
GuildMedia -
UnknownChannelType(Int)
Who an overwrite applies to. Three cases, not two Options: a type Discord
adds after this build is neither a role nor a member, and treating it as
either grants or denies the wrong people.
pub type OverwriteTarget {
RoleTarget(id.Id(id.Role))
MemberTarget(id.Id(id.User))
UnknownTarget(id.Id(id.Overwrite), Int)
}
Constructors
-
-
-
UnknownTarget(id.Id(id.Overwrite), Int)The raw
type, so a caller can recognise one this build cannot name.
pub type OverwriteType {
RoleOverwrite
MemberOverwrite
UnknownOverwriteType(Int)
}
Constructors
-
RoleOverwrite -
MemberOverwrite -
UnknownOverwriteType(Int)
id is a role id or a user id, and only type_ says which. Read it
through overwrite_target.
pub type PermissionOverwrite {
PermissionOverwrite(
id: id.Id(id.Overwrite),
type_: OverwriteType,
allow: permissions.Permissions,
deny: permissions.Permissions,
)
}
Constructors
-
PermissionOverwrite( id: id.Id(id.Overwrite), type_: OverwriteType, allow: permissions.Permissions, deny: permissions.Permissions, )
Minute values, not an ordinal: 60, 1440, 4320, 10080.
pub type ThreadAutoArchiveDuration {
OneHour
OneDay
ThreeDays
OneWeek
UnknownAutoArchiveDuration(Int)
}
Constructors
-
OneHour -
OneDay -
ThreeDays -
OneWeek -
UnknownAutoArchiveDuration(Int)
The body of the two archived thread listings, which page. members holds
only the bot’s own membership, and only of the threads it has joined.
pub type ThreadList {
ThreadList(
threads: List(Channel),
members: List(ThreadMember),
has_more: Bool,
)
}
Constructors
-
ThreadList( threads: List(Channel), members: List(ThreadMember), has_more: Bool, )Arguments
- has_more
-
Another page exists before the oldest thread returned.
One user’s membership of one thread. Mind the collision: Channel.member
is a ThreadMember, and ThreadMember.member is a GuildMember.
pub type ThreadMember {
ThreadMember(
id: option.Option(id.Id(id.Channel)),
user_id: option.Option(id.Id(id.User)),
join_timestamp: String,
flags: Int,
member: option.Option(member.GuildMember),
)
}
Constructors
-
ThreadMember( id: option.Option(id.Id(id.Channel)), user_id: option.Option(id.Id(id.User)), join_timestamp: String, flags: Int, member: option.Option(member.GuildMember), )Arguments
- id
-
The THREAD’s id.
- flags
-
Notification settings. Discord names no flags for these.
- member
-
Only when the request asked for
with_member=true.
pub type ThreadMetadata {
ThreadMetadata(
archived: Bool,
auto_archive_duration: ThreadAutoArchiveDuration,
archive_timestamp: String,
locked: Bool,
invitable: option.Option(Bool),
create_timestamp: option.Option(String),
)
}
Constructors
-
ThreadMetadata( archived: Bool, auto_archive_duration: ThreadAutoArchiveDuration, archive_timestamp: String, locked: Bool, invitable: option.Option(Bool), create_timestamp: option.Option(String), )Arguments
- auto_archive_duration
-
MINUTES.
- archive_timestamp
-
ISO-8601, when the archive flag last changed.
- invitable
-
Private threads only.
- create_timestamp
-
Only threads created after 2022-01-09.
pub type VideoQualityMode {
AutoQuality
FullQuality
UnknownVideoQualityMode(Int)
}
Constructors
-
AutoQuality -
FullQuality -
UnknownVideoQualityMode(Int)
Values
pub fn active_threads_decoder() -> decode.Decoder(ActiveThreads)
pub fn auto_archive_duration_decoder() -> decode.Decoder(
ThreadAutoArchiveDuration,
)
pub fn auto_archive_duration_from_int(
value: Int,
) -> ThreadAutoArchiveDuration
pub fn auto_archive_duration_to_int(
value: ThreadAutoArchiveDuration,
) -> Int
pub fn auto_archive_duration_to_json(
value: ThreadAutoArchiveDuration,
) -> json.Json
pub fn channel_flags(
of chosen: List(ChannelFlag),
) -> flags.Flags(ChannelFlag)
Build the flags an edit sends. Anything decoded off the wire should be
edited with with_flag instead, so bits this build cannot name survive.
pub fn channel_type_decoder() -> decode.Decoder(ChannelType)
pub fn channel_type_from_int(value: Int) -> ChannelType
pub fn channel_type_to_int(value: ChannelType) -> Int
pub fn channel_type_to_json(value: ChannelType) -> json.Json
pub fn decoder() -> decode.Decoder(Channel)
pub fn has_flag(
bits: flags.Flags(ChannelFlag),
flag: ChannelFlag,
) -> Bool
pub fn is_dm(type_: ChannelType) -> Bool
pub fn is_textable(type_: ChannelType) -> Bool
Voice and stage channels have a text chat too.
pub fn is_thread(type_: ChannelType) -> Bool
pub fn is_thread_only(type_: ChannelType) -> Bool
Forums and media channels hold threads only, so they are not textable.
pub fn is_voice(type_: ChannelType) -> Bool
pub const no_channel_flags: flags.Flags(ChannelFlag)
pub fn overwrite_target(
overwrite: PermissionOverwrite,
) -> OverwriteTarget
pub fn overwrite_type_decoder() -> decode.Decoder(OverwriteType)
pub fn overwrite_type_from_int(value: Int) -> OverwriteType
pub fn overwrite_type_to_int(value: OverwriteType) -> Int
pub fn overwrite_type_to_json(value: OverwriteType) -> json.Json
pub fn permission_overwrite_decoder() -> decode.Decoder(
PermissionOverwrite,
)
pub fn permission_overwrite_to_json(
overwrite: PermissionOverwrite,
) -> json.Json
pub fn thread_list_decoder() -> decode.Decoder(ThreadList)
pub fn thread_member_decoder() -> decode.Decoder(ThreadMember)
pub fn thread_metadata_decoder() -> decode.Decoder(ThreadMetadata)
pub fn video_quality_mode_decoder() -> decode.Decoder(
VideoQualityMode,
)
pub fn video_quality_mode_from_int(
value: Int,
) -> VideoQualityMode
pub fn video_quality_mode_to_int(value: VideoQualityMode) -> Int
pub fn video_quality_mode_to_json(
value: VideoQualityMode,
) -> json.Json
pub fn with_flag(
bits: flags.Flags(ChannelFlag),
flag: ChannelFlag,
) -> flags.Flags(ChannelFlag)
pub fn without_flag(
bits: flags.Flags(ChannelFlag),
flag: ChannelFlag,
) -> flags.Flags(ChannelFlag)