diff --git a/src/builder/create_forum_post.rs b/src/builder/create_forum_post.rs index 0ae3147add9..c631aed4cee 100644 --- a/src/builder/create_forum_post.rs +++ b/src/builder/create_forum_post.rs @@ -98,7 +98,7 @@ impl<'a> CreateForumPost<'a> { /// /// Returns [`Error::Http`] if the current user lacks permission, or if invalid data is given. #[cfg(feature = "http")] - pub async fn execute(self, http: &Http, channel_id: ChannelId) -> Result { + pub async fn execute(self, http: &Http, channel_id: ChannelId) -> Result { let files = self.message.attachments.new_attachments(); http.create_forum_post(channel_id, &self, files, self.audit_log_reason).await } diff --git a/src/builder/create_thread.rs b/src/builder/create_thread.rs index 04b6711ca40..24f5ddbbd94 100644 --- a/src/builder/create_thread.rs +++ b/src/builder/create_thread.rs @@ -107,7 +107,7 @@ impl<'a> CreateThread<'a> { http: &Http, channel_id: ChannelId, message_id: Option, - ) -> Result { + ) -> Result { match message_id { Some(id) => { http.create_thread_from_message(channel_id, id, &self, self.audit_log_reason).await diff --git a/src/http/client.rs b/src/http/client.rs index 16398f7e333..db19fab3fdd 100644 --- a/src/http/client.rs +++ b/src/http/client.rs @@ -435,7 +435,7 @@ impl Http { message_id: MessageId, map: &impl serde::Serialize, audit_log_reason: Option<&str>, - ) -> Result { + ) -> Result { let body = to_vec(map)?; self.fire(Request { @@ -458,7 +458,7 @@ impl Http { channel_id: ChannelId, map: &impl serde::Serialize, audit_log_reason: Option<&str>, - ) -> Result { + ) -> Result { let body = to_vec(map)?; self.fire(Request { @@ -481,7 +481,7 @@ impl Http { map: &impl serde::Serialize, files: Vec>, audit_log_reason: Option<&str>, - ) -> Result { + ) -> Result { self.fire(Request { body: None, multipart: Some(Multipart { diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs index 0679152c18c..0778b27ffa6 100644 --- a/src/model/channel/channel_id.rs +++ b/src/model/channel/channel_id.rs @@ -319,7 +319,7 @@ impl ChannelId { http: &Http, message_id: MessageId, builder: CreateThread<'_>, - ) -> Result { + ) -> Result { builder.execute(http, self, Some(message_id)).await } @@ -333,7 +333,7 @@ impl ChannelId { self, http: &Http, builder: CreateThread<'_>, - ) -> Result { + ) -> Result { builder.execute(http, self, None).await } @@ -346,7 +346,7 @@ impl ChannelId { self, http: &Http, builder: CreateForumPost<'_>, - ) -> Result { + ) -> Result { builder.execute(http, self).await } diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs index a1846d18f1a..9e7abb33be1 100644 --- a/src/model/channel/message.rs +++ b/src/model/channel/message.rs @@ -107,7 +107,7 @@ pub struct Message { /// [`Interaction`]: crate::model::application::Interaction pub interaction_metadata: Option>, /// The thread that was started from this message, includes thread member object. - pub thread: Option>, + pub thread: Option>, /// The components of this message #[serde(default, deserialize_with = "deserialize_components")] pub components: FixedArray, diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs index f5f0b22bdb6..e74b035a428 100644 --- a/src/model/channel/mod.rs +++ b/src/model/channel/mod.rs @@ -45,16 +45,32 @@ impl From for GenericChannelId { } impl GenericChannelId { + /// Copies this ID into a [`ChannelId`] and a [`ThreadId`]. + /// + /// It is only correct to use this when you use both returned values, + /// otherwise use [`Self::expect_channel`] or [`Self::expect_thread`]. #[must_use] pub fn split(self) -> (ChannelId, ThreadId) { (self.expect_channel(), self.expect_thread()) } + /// Converts the type of this Id to [`ChannelId`]. + /// + /// This converts the type without changing the inner value, therefore, + /// is only correct when you have knowledge which is not in the type system. + /// + /// This should be used as rarely as [`Option::expect`]. #[must_use] pub fn expect_channel(self) -> ChannelId { ChannelId::new(self.get()) } + /// Converts the type of this Id to [`ThreadId`]. + /// + /// This converts the type without changing the inner value, therefore, + /// is only correct when you have knowledge which is not in the type system. + /// + /// This should be used as rarely as [`Option::expect`]. #[must_use] pub fn expect_thread(self) -> ThreadId { ThreadId::new(self.get()) @@ -449,7 +465,7 @@ pub struct StageInstance { #[non_exhaustive] pub struct ThreadsData { /// The threads channels. - pub threads: FixedArray, + pub threads: FixedArray, /// A thread member for each returned thread the current user has joined. pub members: FixedArray, /// Whether there are potentially more threads that could be returned on a subsequent call. diff --git a/src/model/channel/thread.rs b/src/model/channel/thread.rs index 7f18e9f385c..911888f097c 100644 --- a/src/model/channel/thread.rs +++ b/src/model/channel/thread.rs @@ -7,6 +7,10 @@ use crate::internal::prelude::*; use crate::model::utils::is_false; impl ThreadId { + /// Converts the type of this Id to [`GenericChannelId`]. + /// + /// This allows you to call methods which are shared between channels and threads, and does not + /// change the inner value at all. #[must_use] pub fn widen(self) -> GenericChannelId { self.into() diff --git a/src/model/event.rs b/src/model/event.rs index 8e6f0b4b43c..d274a51126d 100644 --- a/src/model/event.rs +++ b/src/model/event.rs @@ -162,7 +162,7 @@ pub struct GuildCreateEvent { pub guild: Guild, } -// Manual impl needed to insert guild_id fields in GuildChannel, Member, Role +// Manual impl needed to insert guild_id fields in GuildChannel, GuildThread, Member, Role impl<'de> Deserialize<'de> for GuildCreateEvent { fn deserialize>(deserializer: D) -> StdResult { let mut guild: Guild = Guild::deserialize(deserializer)?; diff --git a/src/model/guild/audit_log/mod.rs b/src/model/guild/audit_log/mod.rs index 277819b10ca..69831988539 100644 --- a/src/model/guild/audit_log/mod.rs +++ b/src/model/guild/audit_log/mod.rs @@ -330,7 +330,7 @@ pub struct AuditLogs { /// /// Threads referenced in THREAD_CREATE and THREAD_UPDATE events are included in the threads /// map since archived threads might not be kept in memory by clients. - pub threads: FixedArray, + pub threads: FixedArray, /// List of users referenced in the audit log. pub users: ExtractMap, /// List of webhooks referenced in the audit log.