1use crate::types::{self, ButtonStyle};
4
5#[derive(Debug, Clone)]
7pub struct Button(types::Button);
8
9impl Button {
10 fn styled(style: ButtonStyle, custom_id: Option<String>, label: String) -> Self {
11 Self(types::Button {
12 id: None,
13 style,
14 label: Some(label),
15 emoji: None,
16 custom_id,
17 url: None,
18 disabled: false,
19 })
20 }
21
22 #[must_use]
24 pub fn primary(custom_id: impl Into<String>, label: impl Into<String>) -> Self {
25 Self::styled(ButtonStyle::Primary, Some(custom_id.into()), label.into())
26 }
27
28 #[must_use]
30 pub fn secondary(custom_id: impl Into<String>, label: impl Into<String>) -> Self {
31 Self::styled(ButtonStyle::Secondary, Some(custom_id.into()), label.into())
32 }
33
34 #[must_use]
36 pub fn success(custom_id: impl Into<String>, label: impl Into<String>) -> Self {
37 Self::styled(ButtonStyle::Success, Some(custom_id.into()), label.into())
38 }
39
40 #[must_use]
42 pub fn danger(custom_id: impl Into<String>, label: impl Into<String>) -> Self {
43 Self::styled(ButtonStyle::Danger, Some(custom_id.into()), label.into())
44 }
45
46 #[must_use]
48 pub fn link(url: impl Into<String>, label: impl Into<String>) -> Self {
49 let mut b = Self::styled(ButtonStyle::Link, None, label.into());
50 b.0.url = Some(url.into());
51 b
52 }
53
54 #[must_use]
56 pub fn emoji(mut self, emoji: impl Into<String>) -> Self {
57 self.0.emoji = Some(emoji.into());
58 self
59 }
60
61 #[must_use]
63 pub fn disabled(mut self, disabled: bool) -> Self {
64 self.0.disabled = disabled;
65 self
66 }
67
68 #[must_use]
70 pub fn build(self) -> types::Button {
71 self.0
72 }
73}