serenity/builder/
edit_thread.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)]
11#[must_use]
12pub struct EditThread<'a> {
13 #[serde(skip_serializing_if = "Option::is_none")]
14 name: Option<String>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 archived: Option<bool>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 auto_archive_duration: Option<AutoArchiveDuration>,
19 #[serde(skip_serializing_if = "Option::is_none")]
20 locked: Option<bool>,
21 #[serde(skip_serializing_if = "Option::is_none")]
22 invitable: Option<bool>,
23 #[serde(skip_serializing_if = "Option::is_none")]
24 rate_limit_per_user: Option<u16>,
25 #[serde(skip_serializing_if = "Option::is_none")]
26 flags: Option<ChannelFlags>,
27 #[serde(skip_serializing_if = "Option::is_none")]
28 applied_tags: Option<Vec<ForumTagId>>,
29
30 #[serde(skip)]
31 audit_log_reason: Option<&'a str>,
32}
33
34impl<'a> EditThread<'a> {
35 pub fn new() -> Self {
37 Self::default()
38 }
39
40 pub fn name(mut self, name: impl Into<String>) -> Self {
44 self.name = Some(name.into());
45 self
46 }
47
48 pub fn auto_archive_duration(mut self, duration: AutoArchiveDuration) -> Self {
50 self.auto_archive_duration = Some(duration);
51 self
52 }
53
54 pub fn archived(mut self, archived: bool) -> Self {
59 self.archived = Some(archived);
60 self
61 }
62
63 pub fn locked(mut self, lock: bool) -> Self {
65 self.locked = Some(lock);
66 self
67 }
68
69 pub fn invitable(mut self, invitable: bool) -> Self {
73 self.invitable = Some(invitable);
74 self
75 }
76
77 pub fn rate_limit_per_user(mut self, rate_limit_per_user: u16) -> Self {
81 self.rate_limit_per_user = Some(rate_limit_per_user);
82 self
83 }
84
85 pub fn flags(mut self, flags: ChannelFlags) -> Self {
88 self.flags = Some(flags);
89 self
90 }
91
92 pub fn applied_tags(mut self, applied_tags: impl IntoIterator<Item = ForumTagId>) -> Self {
94 self.applied_tags = Some(applied_tags.into_iter().collect());
95 self
96 }
97
98 pub fn audit_log_reason(mut self, reason: &'a str) -> Self {
100 self.audit_log_reason = Some(reason);
101 self
102 }
103}
104
105#[cfg(feature = "http")]
106#[async_trait::async_trait]
107impl Builder for EditThread<'_> {
108 type Context<'ctx> = ChannelId;
109 type Built = GuildChannel;
110
111 async fn execute(
117 self,
118 cache_http: impl CacheHttp,
119 ctx: Self::Context<'_>,
120 ) -> Result<Self::Built> {
121 cache_http.http().edit_thread(ctx, &self, self.audit_log_reason).await
122 }
123}