glyde/model/embed
Message embeds, as they arrive. Every top-level field is optional: the commonest embed is a link preview with no title, description or colour.
glyde/payload/embed is the send shape, which drops what Discord ignores.
Types
pub type Embed {
Embed(
title: option.Option(String),
type_: option.Option(EmbedType),
description: option.Option(String),
url: option.Option(String),
timestamp: option.Option(String),
color: option.Option(Int),
footer: option.Option(EmbedFooter),
image: option.Option(EmbedMedia),
thumbnail: option.Option(EmbedMedia),
video: option.Option(EmbedMedia),
provider: option.Option(EmbedProvider),
author: option.Option(EmbedAuthor),
fields: List(EmbedField),
flags: flags.Flags(EmbedFlag),
)
}
Constructors
-
Embed( title: option.Option(String), type_: option.Option(EmbedType), description: option.Option(String), url: option.Option(String), timestamp: option.Option(String), color: option.Option(Int), footer: option.Option(EmbedFooter), image: option.Option(EmbedMedia), thumbnail: option.Option(EmbedMedia), video: option.Option(EmbedMedia), provider: option.Option(EmbedProvider), author: option.Option(EmbedAuthor), fields: List(EmbedField), flags: flags.Flags(EmbedFlag), )Arguments
- title
-
Max 256 characters.
- type_
-
An open set: Discord ships values it has not documented.
- description
-
Max 4096 characters.
- url
-
Embeds sharing a url are merged into one by the client.
- timestamp
-
ISO-8601.
- color
-
0xRRGGBB.
- video
-
Receive only.
- provider
-
Receive only.
- fields
-
Max 25.
pub type EmbedAuthor {
EmbedAuthor(
name: String,
url: option.Option(String),
icon_url: option.Option(String),
proxy_icon_url: option.Option(String),
)
}
Constructors
-
EmbedAuthor( name: String, url: option.Option(String), icon_url: option.Option(String), proxy_icon_url: option.Option(String), )Arguments
- name
-
Max 256 characters.
- proxy_icon_url
-
Receive only.
pub type EmbedField {
EmbedField(name: String, value: String, inline: Bool)
}
Constructors
-
EmbedField(name: String, value: String, inline: Bool)namemax 256,valuemax 1024, and 6000 characters across the embed.
pub type EmbedFlag {
IsContentInventoryEntry
}
Constructors
-
IsContentInventoryEntryThe embed is a content inventory entry, which a bot never sends.
pub type EmbedFlags =
flags.Flags(EmbedFlag)
pub type EmbedFooter {
EmbedFooter(
text: String,
icon_url: option.Option(String),
proxy_icon_url: option.Option(String),
)
}
Constructors
-
EmbedFooter( text: String, icon_url: option.Option(String), proxy_icon_url: option.Option(String), )Arguments
- text
-
Max 2048 characters.
- proxy_icon_url
-
Receive only.
One record for image, thumbnail and video.
pub type EmbedMedia {
EmbedMedia(
url: option.Option(String),
proxy_url: option.Option(String),
height: option.Option(Int),
width: option.Option(Int),
content_type: option.Option(String),
placeholder: option.Option(String),
placeholder_version: option.Option(Int),
description: option.Option(String),
flags: flags.Flags(EmbedMediaFlag),
)
}
Constructors
-
EmbedMedia( url: option.Option(String), proxy_url: option.Option(String), height: option.Option(Int), width: option.Option(Int), content_type: option.Option(String), placeholder: option.Option(String), placeholder_version: option.Option(Int), description: option.Option(String), flags: flags.Flags(EmbedMediaFlag), )Arguments
- placeholder
-
A thumbhash: a blurred preview to paint while the image loads.
- description
-
Alt text.
pub type EmbedMediaFlag {
IsAnimated
}
Constructors
-
IsAnimated
Its own type, not the attachment one: Discord documents a separate table for embed media, and today it names a single bit.
pub type EmbedMediaFlags =
flags.Flags(EmbedMediaFlag)
pub type EmbedProvider {
EmbedProvider(
name: option.Option(String),
url: option.Option(String),
)
}
Constructors
-
EmbedProvider( name: option.Option(String), url: option.Option(String), )
Discord’s documented embed types, plus the tail for the ones it ships
without documenting. Only Rich is ever sent by a bot; the rest are what
the client made of a link.
pub type EmbedType {
Rich
Image
Video
Gifv
Article
Link
PollResult
AutoModerationMessage
UnknownEmbedType(String)
}
Constructors
-
Rich -
Image -
Video -
Gifv -
Article -
Link -
PollResult -
AutoModerationMessage -
UnknownEmbedType(String)
Values
pub fn author_decoder() -> decode.Decoder(EmbedAuthor)
pub fn decoder() -> decode.Decoder(Embed)
pub fn embed_type_decoder() -> decode.Decoder(EmbedType)
pub fn embed_type_from_string(value: String) -> EmbedType
pub fn embed_type_to_string(value: EmbedType) -> String
pub fn field_decoder() -> decode.Decoder(EmbedField)
pub fn footer_decoder() -> decode.Decoder(EmbedFooter)
pub fn has_flag(
bits: flags.Flags(EmbedFlag),
flag: EmbedFlag,
) -> Bool
pub fn has_media_flag(
bits: flags.Flags(EmbedMediaFlag),
flag: EmbedMediaFlag,
) -> Bool
pub fn media_decoder() -> decode.Decoder(EmbedMedia)
pub fn provider_decoder() -> decode.Decoder(EmbedProvider)