Skip to main content

mutiny_rs/builders/
create_embed.rs

1use serde::Serialize;
2
3#[derive(Debug, Clone, Serialize, Default)]
4pub struct SendableEmbed {
5    #[serde(rename = "type")]
6    pub kind: String,
7
8    #[serde(skip_serializing_if = "Option::is_none")]
9    pub title: Option<String>,
10
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub description: Option<String>,
13
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub url: Option<String>,
16
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub colour: Option<String>,
19
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub icon_url: Option<String>,
22
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub media: Option<String>,
25}
26
27#[derive(Debug, Clone, Serialize, Default)]
28pub struct CreateEmbed(SendableEmbed);
29
30impl CreateEmbed {
31    pub fn new() -> Self {
32        Self(SendableEmbed {
33            kind: "Website".to_string(),
34            ..Default::default()
35        })
36    }
37
38    pub fn title(mut self, title: impl Into<String>) -> Self {
39        self.0.title = Some(title.into());
40        self
41    }
42
43    pub fn description(mut self, desc: impl Into<String>) -> Self {
44        self.0.description = Some(desc.into());
45        self
46    }
47
48    pub fn color(mut self, color: impl Into<String>) -> Self {
49        self.0.colour = Some(color.into());
50        self
51    }
52
53    pub fn icon(mut self, url: impl Into<String>) -> Self {
54        self.0.icon_url = Some(url.into());
55        self
56    }
57}