Skip to main content

twilight_util/builder/message/
checkbox.rs

1use twilight_model::channel::message::component::Checkbox;
2
3/// Create a checkbox from a builder.
4#[derive(Clone, Debug, Eq, PartialEq)]
5#[must_use = "must be built into a checkbox"]
6pub struct CheckboxBuilder(Checkbox);
7impl CheckboxBuilder {
8    /// Create a new checkbox builder
9    pub fn new(custom_id: impl Into<String>) -> Self {
10        Self(Checkbox {
11            id: None,
12            custom_id: custom_id.into(),
13            default: None,
14        })
15    }
16
17    /// Set the identifier of this checkbox.
18    pub const fn id(mut self, id: i32) -> Self {
19        self.0.id.replace(id);
20
21        self
22    }
23
24    /// Set if this checkbox is checked by default
25    pub const fn default(mut self, default: bool) -> Self {
26        self.0.default.replace(default);
27
28        self
29    }
30
31    /// Build into a checkbox
32    pub fn build(self) -> Checkbox {
33        self.0
34    }
35}