Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/builder/create_forum_post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GuildChannel> {
pub async fn execute(self, http: &Http, channel_id: ChannelId) -> Result<GuildThread> {
let files = self.message.attachments.new_attachments();
http.create_forum_post(channel_id, &self, files, self.audit_log_reason).await
}
Expand Down
2 changes: 1 addition & 1 deletion src/builder/create_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<'a> CreateThread<'a> {
http: &Http,
channel_id: ChannelId,
message_id: Option<MessageId>,
) -> Result<GuildChannel> {
) -> Result<GuildThread> {
match message_id {
Some(id) => {
http.create_thread_from_message(channel_id, id, &self, self.audit_log_reason).await
Expand Down
6 changes: 3 additions & 3 deletions src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ impl Http {
message_id: MessageId,
map: &impl serde::Serialize,
audit_log_reason: Option<&str>,
) -> Result<GuildChannel> {
) -> Result<GuildThread> {
let body = to_vec(map)?;

self.fire(Request {
Expand All @@ -458,7 +458,7 @@ impl Http {
channel_id: ChannelId,
map: &impl serde::Serialize,
audit_log_reason: Option<&str>,
) -> Result<GuildChannel> {
) -> Result<GuildThread> {
let body = to_vec(map)?;

self.fire(Request {
Expand All @@ -481,7 +481,7 @@ impl Http {
map: &impl serde::Serialize,
files: Vec<CreateAttachment<'_>>,
audit_log_reason: Option<&str>,
) -> Result<GuildChannel> {
) -> Result<GuildThread> {
self.fire(Request {
body: None,
multipart: Some(Multipart {
Expand Down
6 changes: 3 additions & 3 deletions src/model/channel/channel_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ impl ChannelId {
http: &Http,
message_id: MessageId,
builder: CreateThread<'_>,
) -> Result<GuildChannel> {
) -> Result<GuildThread> {
builder.execute(http, self, Some(message_id)).await
}

Expand All @@ -333,7 +333,7 @@ impl ChannelId {
self,
http: &Http,
builder: CreateThread<'_>,
) -> Result<GuildChannel> {
) -> Result<GuildThread> {
builder.execute(http, self, None).await
}

Expand All @@ -346,7 +346,7 @@ impl ChannelId {
self,
http: &Http,
builder: CreateForumPost<'_>,
) -> Result<GuildChannel> {
) -> Result<GuildThread> {
builder.execute(http, self).await
}

Expand Down
2 changes: 1 addition & 1 deletion src/model/channel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub struct Message {
/// [`Interaction`]: crate::model::application::Interaction
pub interaction_metadata: Option<Box<MessageInteractionMetadata>>,
/// The thread that was started from this message, includes thread member object.
pub thread: Option<Box<GuildChannel>>,
pub thread: Option<Box<GuildThread>>,
/// The components of this message
#[serde(default, deserialize_with = "deserialize_components")]
pub components: FixedArray<ActionRow>,
Expand Down
18 changes: 17 additions & 1 deletion src/model/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,32 @@ impl From<ChannelId> 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())
Expand Down Expand Up @@ -449,7 +465,7 @@ pub struct StageInstance {
#[non_exhaustive]
pub struct ThreadsData {
/// The threads channels.
pub threads: FixedArray<GuildChannel>,
pub threads: FixedArray<GuildThread>,
/// A thread member for each returned thread the current user has joined.
pub members: FixedArray<ThreadMember>,
/// Whether there are potentially more threads that could be returned on a subsequent call.
Expand Down
4 changes: 4 additions & 0 deletions src/model/channel/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/model/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<D: Deserializer<'de>>(deserializer: D) -> StdResult<Self, D::Error> {
let mut guild: Guild = Guild::deserialize(deserializer)?;
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/audit_log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GuildChannel>,
pub threads: FixedArray<GuildThread>,
/// List of users referenced in the audit log.
pub users: ExtractMap<UserId, User>,
/// List of webhooks referenced in the audit log.
Expand Down
Loading