#[cfg(feature = "model")]
use crate::builder::CreateEmbed;
#[cfg(feature = "model")]
use crate::internal::prelude::*;
#[cfg(feature = "utils")]
use crate::utils::Colour;
#[cfg(feature = "model")]
use crate::utils;
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Embed {
pub author: Option<EmbedAuthor>,
#[cfg(feature = "utils")]
#[serde(default, rename = "color")]
pub colour: Colour,
#[cfg(not(feature = "utils"))]
#[serde(default, rename = "color")]
pub colour: u32,
pub description: Option<String>,
#[serde(default)]
pub fields: Vec<EmbedField>,
pub footer: Option<EmbedFooter>,
pub image: Option<EmbedImage>,
#[serde(rename = "type")]
pub kind: String,
pub provider: Option<EmbedProvider>,
pub thumbnail: Option<EmbedThumbnail>,
pub timestamp: Option<String>,
pub title: Option<String>,
pub url: Option<String>,
pub video: Option<EmbedVideo>,
#[serde(skip)]
pub(crate) _nonexhaustive: (),
}
#[cfg(feature = "model")]
impl Embed {
#[inline]
pub fn fake<F>(f: F) -> Value
where F: FnOnce(&mut CreateEmbed) -> &mut CreateEmbed {
let mut create_embed = CreateEmbed::default();
f(&mut create_embed);
let map = utils::hashmap_to_json_map(create_embed.0);
Value::Object(map)
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedAuthor {
pub icon_url: Option<String>,
pub name: String,
pub proxy_icon_url: Option<String>,
pub url: Option<String>,
#[serde(skip)]
pub(crate) _nonexhaustive: (),
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedField {
pub inline: bool,
pub name: String,
pub value: String,
#[serde(skip)]
pub(crate) _nonexhaustive: (),
}
impl EmbedField {
pub fn new<T, U>(name: T, value: U, inline: bool) -> Self
where T: Into<String>, U: Into<String> {
Self::_new(name.into(), value.into(), inline)
}
fn _new(name: String, value: String, inline: bool) -> Self {
Self {
name,
value,
inline,
_nonexhaustive: (),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedFooter {
pub icon_url: Option<String>,
pub proxy_icon_url: Option<String>,
pub text: String,
#[serde(skip)]
pub(crate) _nonexhaustive: (),
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedImage {
pub height: u64,
pub proxy_url: String,
pub url: String,
pub width: u64,
#[serde(skip)]
pub(crate) _nonexhaustive: (),
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedProvider {
pub name: String,
pub url: Option<String>,
#[serde(skip)]
pub(crate) _nonexhaustive: (),
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedThumbnail {
pub height: u64,
pub proxy_url: String,
pub url: String,
pub width: u64,
#[serde(skip)]
pub(crate) _nonexhaustive: (),
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedVideo {
pub height: u64,
pub url: String,
pub width: u64,
#[serde(skip)]
pub(crate) _nonexhaustive: (),
}