discord_webhook2/message/poll/
media.rs

1use crate::message::emoji::Emoji;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct PollMedia {
6    /// The text of the field
7    text: Option<String>,
8    /// The emoji of the field
9    emoji: Option<Emoji>,
10}
11
12impl PollMedia {
13    pub fn new() -> Self {
14        Self {
15            text: None,
16            emoji: None,
17        }
18    }
19
20    pub fn text(mut self, text: impl Into<String>) -> Self {
21        self.text = Some(text.into());
22        self
23    }
24
25    pub fn emoji<Func>(mut self, function: Func) -> Self
26    where
27        Func: FnOnce(Emoji) -> Emoji,
28    {
29        self.emoji = Some(function(Emoji::new()));
30        self
31    }
32}
33
34impl Default for PollMedia {
35    fn default() -> Self {
36        Self::new()
37    }
38}