serenity/builder/
edit_guild_welcome_screen.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, Default, Serialize)]
13#[must_use]
14pub struct EditGuildWelcomeScreen<'a> {
15 #[serde(skip_serializing_if = "Option::is_none")]
16 enabled: Option<bool>,
17 #[serde(skip_serializing_if = "Vec::is_empty")]
18 welcome_channels: Vec<CreateGuildWelcomeChannel>,
19 #[serde(skip_serializing_if = "Option::is_none")]
20 description: Option<String>,
21
22 #[serde(skip)]
23 audit_log_reason: Option<&'a str>,
24}
25
26impl<'a> EditGuildWelcomeScreen<'a> {
27 pub fn new() -> Self {
29 Self::default()
30 }
31
32 pub fn enabled(mut self, enabled: bool) -> Self {
34 self.enabled = Some(enabled);
35 self
36 }
37
38 pub fn description(mut self, description: impl Into<String>) -> Self {
40 self.description = Some(description.into());
41 self
42 }
43
44 pub fn add_welcome_channel(mut self, channel: CreateGuildWelcomeChannel) -> Self {
45 self.welcome_channels.push(channel);
46 self
47 }
48
49 pub fn set_welcome_channels(mut self, channels: Vec<CreateGuildWelcomeChannel>) -> Self {
51 self.welcome_channels = channels;
52 self
53 }
54
55 pub fn audit_log_reason(mut self, reason: &'a str) -> Self {
57 self.audit_log_reason = Some(reason);
58 self
59 }
60}
61
62#[cfg(feature = "http")]
63#[async_trait::async_trait]
64impl Builder for EditGuildWelcomeScreen<'_> {
65 type Context<'ctx> = GuildId;
66 type Built = GuildWelcomeScreen;
67
68 async fn execute(
78 self,
79 cache_http: impl CacheHttp,
80 ctx: Self::Context<'_>,
81 ) -> Result<Self::Built> {
82 cache_http.http().edit_guild_welcome_screen(ctx, &self, self.audit_log_reason).await
83 }
84}
85
86#[derive(Clone, Debug, Serialize)]
90#[must_use]
91pub struct CreateGuildWelcomeChannel(GuildWelcomeChannel);
92
93impl CreateGuildWelcomeChannel {
94 pub fn new(channel_id: ChannelId, description: String) -> Self {
95 Self(GuildWelcomeChannel {
96 channel_id,
97 description,
98 emoji: None,
99 })
100 }
101
102 pub fn id(mut self, id: impl Into<ChannelId>) -> Self {
104 self.0.channel_id = id.into();
105 self
106 }
107
108 pub fn description(mut self, description: impl Into<String>) -> Self {
110 self.0.description = description.into();
111 self
112 }
113
114 pub fn emoji(mut self, emoji: GuildWelcomeChannelEmoji) -> Self {
116 self.0.emoji = Some(emoji);
117 self
118 }
119}