discord_webhook2/message/poll/
create.rs1use crate::message::poll::answer::PollAnswer;
2use crate::message::poll::layout_type::PollLayoutType;
3use crate::message::poll::media::PollMedia;
4use serde::{Deserialize, Serialize};
5
6#[derive(Serialize, Deserialize, Debug, Clone)]
7pub struct PollCreate {
8 question: PollMedia,
10 answers: Vec<PollAnswer>,
12 duration: Option<u32>,
14 allow_multiselect: Option<bool>,
16 layout_type: Option<PollLayoutType>,
18}
19
20impl PollCreate {
21 pub fn new(question: PollMedia) -> PollCreate {
22 Self {
23 question,
24 answers: vec![],
25 duration: None,
26 allow_multiselect: None,
27 layout_type: None,
28 }
29 }
30
31 pub fn answer<Func>(mut self, function: Func) -> Self
32 where
33 Func: FnOnce(PollMedia) -> PollMedia,
34 {
35 self.answers
36 .push(PollAnswer::new(function(PollMedia::new())));
37 self
38 }
39}