glyde/model/attachment
A file attached to a message. The Clips-only fields, clip_participants,
clip_created_at and application, are not modelled.
Types
pub type Attachment {
Attachment(
id: id.Id(id.Attachment),
filename: String,
title: option.Option(String),
description: option.Option(String),
content_type: option.Option(String),
size: Int,
url: String,
proxy_url: String,
dimensions: option.Option(Dimensions),
placeholder: option.Option(Placeholder),
ephemeral: Bool,
duration_secs: option.Option(Float),
waveform: option.Option(String),
flags: flags.Flags(AttachmentFlag),
)
}
Constructors
-
Attachment( id: id.Id(id.Attachment), filename: String, title: option.Option(String), description: option.Option(String), content_type: option.Option(String), size: Int, url: String, proxy_url: String, dimensions: option.Option(Dimensions), placeholder: option.Option(Placeholder), ephemeral: Bool, duration_secs: option.Option(Float), waveform: option.Option(String), flags: flags.Flags(AttachmentFlag), )Arguments
- description
-
Alt text, up to 1024 characters.
- size
-
Bytes.
- url
-
A signed CDN URL that expires. Re-fetch the message, do not store it.
- proxy_url
-
The same URL through Discord’s media proxy, and it expires too.
- dimensions
-
Absent for anything that is not an image or a video. Discord sends both sides or neither, so one value carries both.
- placeholder
-
A thumbhash: a blurred preview to paint while the image loads. The version only says how the hash is encoded, so one value carries both.
- ephemeral
-
Garbage collected, so the URL dies before its signature expires.
- duration_secs
-
Voice messages and videos. Discord sends a whole number of seconds as
3, not3.0. - waveform
-
Base64 waveform preview for a voice message.
pub type AttachmentFlag {
IsClip
IsThumbnail
IsRemix
IsSpoiler
IsAnimated
}
Constructors
-
IsClip -
IsThumbnail -
IsRemixDiscord deprecated this one and still sends it.
-
IsSpoiler -
IsAnimated
pub type AttachmentFlags =
flags.Flags(AttachmentFlag)
Pixels. An image or a video has both, anything else has neither.
pub type Dimensions {
Dimensions(width: Int, height: Int)
}
Constructors
-
Dimensions(width: Int, height: Int)
A thumbhash and the layout it is encoded in. Discord documents 1 as the only version so far, so a hash that arrives without one reads as 1.
pub type Placeholder {
Placeholder(hash: String, version: Int)
}
Constructors
-
Placeholder(hash: String, version: Int)
Values
pub fn decoder() -> decode.Decoder(Attachment)
pub fn has_flag(
bits: flags.Flags(AttachmentFlag),
flag: AttachmentFlag,
) -> Bool