#[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 EditGuildWidget<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
enabled: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
channel_id: Option<ChannelId>,
#[serde(skip)]
audit_log_reason: Option<&'a str>,
}
impl<'a> EditGuildWidget<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn enabled(mut self, enabled: bool) -> Self {
self.enabled = Some(enabled);
self
}
pub fn channel_id(mut self, id: impl Into<ChannelId>) -> Self {
self.channel_id = Some(id.into());
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 EditGuildWidget<'_> {
type Context<'ctx> = GuildId;
type Built = GuildWidget;
async fn execute(
self,
cache_http: impl CacheHttp,
ctx: Self::Context<'_>,
) -> Result<Self::Built> {
cache_http.http().edit_guild_widget(ctx, &self, self.audit_log_reason).await
}
}