use serde::{Deserialize, Serialize};
use url::Url;
pub use serde_json::Error;
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct EmbedField {
#[serde(rename = "name")]
pub title: String,
pub value: String,
pub inline: bool,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct EmbedAuthor {
pub name: String,
pub url: Option<Url>,
pub icon_url: Option<Url>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct EmbedThumbnail {
pub url: Url,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct EmbedImage {
pub url: Url,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct EmbedFooter {
pub text: String,
pub icon_url: Option<Url>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct Embed {
pub title: String,
pub description: String,
pub color: Option<u32>,
pub author: Option<EmbedAuthor>,
pub fields: Option<Vec<EmbedField>>,
pub thumbnail: Option<EmbedThumbnail>,
pub image: Option<EmbedImage>,
pub footer: Option<EmbedFooter>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct DiscordMessage {
pub username: Option<String>,
pub avatar_url: Option<Url>,
pub content: String,
pub embeds: Vec<Embed>,
}
impl DiscordMessage {
pub fn to_json(&self) -> serde_json::Result<String> {
serde_json::to_string(self)
}
}