#[cfg(feature = "model")]
use builder::CreateEmbed;
#[cfg(feature = "model")]
use internal::prelude::*;
#[cfg(feature = "utils")]
use utils::Colour;
#[cfg(feature = "model")]
use 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>,
}
#[cfg(feature = "model")]
impl Embed {
#[inline]
pub fn fake<F>(f: F) -> Value
where F: FnOnce(CreateEmbed) -> CreateEmbed {
let map = utils::vecmap_to_json_map(f(CreateEmbed::default()).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>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedField {
pub inline: bool,
pub name: String,
pub value: String,
}
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,
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedFooter {
pub icon_url: Option<String>,
pub proxy_icon_url: Option<String>,
pub text: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedImage {
pub height: u64,
pub proxy_url: String,
pub url: String,
pub width: u64,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedProvider {
pub name: String,
pub url: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedThumbnail {
pub height: u64,
pub proxy_url: String,
pub url: String,
pub width: u64,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EmbedVideo {
pub height: u64,
pub url: String,
pub width: u64,
}