serenity/builder/
edit_guild_widget.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 EditGuildWidget<'a> {
15 #[serde(skip_serializing_if = "Option::is_none")]
16 enabled: Option<bool>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 channel_id: Option<ChannelId>,
19
20 #[serde(skip)]
21 audit_log_reason: Option<&'a str>,
22}
23
24impl<'a> EditGuildWidget<'a> {
25 pub fn new() -> Self {
27 Self::default()
28 }
29
30 pub fn enabled(mut self, enabled: bool) -> Self {
32 self.enabled = Some(enabled);
33 self
34 }
35
36 pub fn channel_id(mut self, id: impl Into<ChannelId>) -> Self {
38 self.channel_id = Some(id.into());
39 self
40 }
41
42 pub fn audit_log_reason(mut self, reason: &'a str) -> Self {
44 self.audit_log_reason = Some(reason);
45 self
46 }
47}
48
49#[cfg(feature = "http")]
50#[async_trait::async_trait]
51impl Builder for EditGuildWidget<'_> {
52 type Context<'ctx> = GuildId;
53 type Built = GuildWidget;
54
55 async fn execute(
65 self,
66 cache_http: impl CacheHttp,
67 ctx: Self::Context<'_>,
68 ) -> Result<Self::Built> {
69 cache_http.http().edit_guild_widget(ctx, &self, self.audit_log_reason).await
70 }
71}