titanium_model/builder/
webhook.rs

1/// Payload for executing a webhook.
2#[derive(Debug, Clone, serde::Serialize, Default)]
3pub struct ExecuteWebhook {
4    #[serde(skip_serializing_if = "Option::is_none")]
5    pub content: Option<String>,
6    #[serde(skip_serializing_if = "Option::is_none")]
7    pub username: Option<String>,
8    #[serde(skip_serializing_if = "Option::is_none")]
9    pub avatar_url: Option<String>,
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub tts: Option<bool>,
12    #[serde(skip_serializing_if = "Vec::is_empty")]
13    pub embeds: Vec<crate::Embed<'static>>,
14    // Note: files and components omitted for brevity, but can be added
15}
16
17/// Builder for executing a Webhook.
18#[derive(Debug, Clone, Default)]
19pub struct WebhookExecuteBuilder<'a> {
20    params: ExecuteWebhook,
21    _phantom: std::marker::PhantomData<&'a ()>,
22}
23
24impl WebhookExecuteBuilder<'_> {
25    /// Create a new `WebhookExecuteBuilder`.
26    #[must_use]
27    pub fn new() -> Self {
28        Self::default()
29    }
30
31    /// Set content.
32    #[inline]
33    pub fn content(mut self, content: impl Into<String>) -> Self {
34        self.params.content = Some(content.into());
35        self
36    }
37
38    /// Set username override.
39    #[inline]
40    pub fn username(mut self, username: impl Into<String>) -> Self {
41        self.params.username = Some(username.into());
42        self
43    }
44
45    /// Set avatar URL override.
46    #[inline]
47    pub fn avatar_url(mut self, url: impl Into<String>) -> Self {
48        self.params.avatar_url = Some(url.into());
49        self
50    }
51
52    /// Set TTS.
53    #[inline]
54    #[must_use]
55    pub fn tts(mut self, tts: bool) -> Self {
56        self.params.tts = Some(tts);
57        self
58    }
59
60    /// Add an embed.
61    #[inline]
62    pub fn embed(mut self, embed: impl Into<crate::Embed<'static>>) -> Self {
63        self.params.embeds.push(embed.into());
64        self
65    }
66
67    /// Add multiple embeds.
68    #[inline]
69    #[must_use]
70    pub fn embeds(mut self, embeds: Vec<crate::Embed<'static>>) -> Self {
71        self.params.embeds.extend(embeds);
72        self
73    }
74
75    /// Build the payload.
76    #[inline]
77    #[must_use]
78    pub fn build(self) -> ExecuteWebhook {
79        self.params
80    }
81}