serenity/builder/
create_stage_instance.rs1#[cfg(feature = "http")]
2use super::Builder;
3#[cfg(feature = "http")]
4use crate::http::CacheHttp;
5#[cfg(feature = "http")]
6use crate::internal::prelude::*;
7use crate::model::prelude::*;
8
9#[derive(Clone, Debug, Serialize)]
13#[must_use]
14pub struct CreateStageInstance<'a> {
15 channel_id: Option<ChannelId>, topic: String,
17 privacy_level: StageInstancePrivacyLevel,
18 #[serde(skip_serializing_if = "Option::is_none")]
19 send_start_notification: Option<bool>,
20
21 #[serde(skip)]
22 audit_log_reason: Option<&'a str>,
23}
24
25impl<'a> CreateStageInstance<'a> {
26 pub fn new(topic: impl Into<String>) -> Self {
28 Self {
29 channel_id: None,
30 topic: topic.into(),
31 privacy_level: StageInstancePrivacyLevel::default(),
32 send_start_notification: None,
33 audit_log_reason: None,
34 }
35 }
36
37 pub fn topic(mut self, topic: impl Into<String>) -> Self {
40 self.topic = topic.into();
41 self
42 }
43
44 pub fn send_start_notification(mut self, send_start_notification: bool) -> Self {
46 self.send_start_notification = Some(send_start_notification);
47 self
48 }
49
50 pub fn audit_log_reason(mut self, reason: &'a str) -> Self {
52 self.audit_log_reason = Some(reason);
53 self
54 }
55}
56
57#[cfg(feature = "http")]
58#[async_trait::async_trait]
59impl Builder for CreateStageInstance<'_> {
60 type Context<'ctx> = ChannelId;
61 type Built = StageInstance;
62
63 async fn execute(
69 mut self,
70 cache_http: impl CacheHttp,
71 ctx: Self::Context<'_>,
72 ) -> Result<StageInstance> {
73 self.channel_id = Some(ctx);
74 cache_http.http().create_stage_instance(&self, self.audit_log_reason).await
75 }
76}