titanium_model/builder/
scheduled.rs1use crate::TitanString;
2
3#[derive(Debug, Clone, serde::Serialize, Default)]
5pub struct CreateScheduledEvent<'a> {
6 pub name: TitanString<'a>,
7 pub privacy_level: crate::scheduled::ScheduledEventPrivacyLevel,
8 pub scheduled_start_time: TitanString<'a>,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 pub scheduled_end_time: Option<TitanString<'a>>,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 pub description: Option<TitanString<'a>>,
13 pub entity_type: crate::scheduled::ScheduledEventEntityType,
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub channel_id: Option<crate::Snowflake>,
16 #[serde(skip_serializing_if = "Option::is_none")]
17 pub entity_metadata: Option<crate::scheduled::ScheduledEventEntityMetadata<'a>>,
18 #[serde(skip_serializing_if = "Option::is_none")]
19 pub image: Option<TitanString<'a>>, }
21
22#[derive(Debug, Clone)]
24pub struct ScheduledEventBuilder<'a> {
25 params: CreateScheduledEvent<'a>,
26}
27
28impl<'a> ScheduledEventBuilder<'a> {
29 pub fn new(
31 name: impl Into<TitanString<'a>>,
32 start_time: impl Into<TitanString<'a>>,
33 entity_type: crate::scheduled::ScheduledEventEntityType,
34 ) -> Self {
35 Self {
36 params: CreateScheduledEvent {
37 name: name.into(),
38 scheduled_start_time: start_time.into(),
39 entity_type,
40 privacy_level: crate::scheduled::ScheduledEventPrivacyLevel::GuildOnly,
41 ..Default::default()
42 },
43 }
44 }
45
46 #[inline]
48 pub fn description(mut self, description: impl Into<TitanString<'a>>) -> Self {
49 self.params.description = Some(description.into());
50 self
51 }
52
53 #[inline]
55 pub fn end_time(mut self, time: impl Into<TitanString<'a>>) -> Self {
56 self.params.scheduled_end_time = Some(time.into());
57 self
58 }
59
60 #[inline]
62 pub fn channel_id(mut self, id: impl Into<crate::Snowflake>) -> Self {
63 self.params.channel_id = Some(id.into());
64 self
65 }
66
67 #[inline]
69 pub fn location(mut self, location: impl Into<TitanString<'a>>) -> Self {
70 self.params.entity_metadata = Some(crate::scheduled::ScheduledEventEntityMetadata {
71 location: Some(location.into()),
72 });
73 self
74 }
75
76 #[inline]
78 pub fn image(mut self, image: impl Into<TitanString<'a>>) -> Self {
79 self.params.image = Some(image.into());
80 self
81 }
82
83 #[inline]
85 #[must_use]
86 pub fn build(self) -> CreateScheduledEvent<'a> {
87 self.params
88 }
89}