#[cfg(feature = "http")]
use super::Builder;
#[cfg(feature = "http")]
use crate::http::CacheHttp;
#[cfg(feature = "http")]
use crate::internal::prelude::*;
use crate::model::prelude::*;
#[derive(Clone, Debug, Default, Serialize)]
#[must_use]
pub struct EditGuildWelcomeScreen<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
enabled: Option<bool>,
#[serde(skip_serializing_if = "Vec::is_empty")]
welcome_channels: Vec<CreateGuildWelcomeChannel>,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
#[serde(skip)]
audit_log_reason: Option<&'a str>,
}
impl<'a> EditGuildWelcomeScreen<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn enabled(mut self, enabled: bool) -> Self {
self.enabled = Some(enabled);
self
}
pub fn description(mut self, description: impl Into<String>) -> Self {
self.description = Some(description.into());
self
}
pub fn add_welcome_channel(mut self, channel: CreateGuildWelcomeChannel) -> Self {
self.welcome_channels.push(channel);
self
}
pub fn set_welcome_channels(mut self, channels: Vec<CreateGuildWelcomeChannel>) -> Self {
self.welcome_channels = channels;
self
}
pub fn audit_log_reason(mut self, reason: &'a str) -> Self {
self.audit_log_reason = Some(reason);
self
}
}
#[cfg(feature = "http")]
#[async_trait::async_trait]
impl Builder for EditGuildWelcomeScreen<'_> {
type Context<'ctx> = GuildId;
type Built = GuildWelcomeScreen;
async fn execute(
self,
cache_http: impl CacheHttp,
ctx: Self::Context<'_>,
) -> Result<Self::Built> {
cache_http.http().edit_guild_welcome_screen(ctx, &self, self.audit_log_reason).await
}
}
#[derive(Clone, Debug, Serialize)]
#[must_use]
pub struct CreateGuildWelcomeChannel(GuildWelcomeChannel);
impl CreateGuildWelcomeChannel {
pub fn new(channel_id: ChannelId, description: String) -> Self {
Self(GuildWelcomeChannel {
channel_id,
description,
emoji: None,
})
}
pub fn id(mut self, id: impl Into<ChannelId>) -> Self {
self.0.channel_id = id.into();
self
}
pub fn description(mut self, description: impl Into<String>) -> Self {
self.0.description = description.into();
self
}
pub fn emoji(mut self, emoji: GuildWelcomeChannelEmoji) -> Self {
self.0.emoji = Some(emoji);
self
}
}