diff --git a/src/api/channels/channels.rs b/src/api/channels/channels.rs index ddefed3..cbe481c 100644 --- a/src/api/channels/channels.rs +++ b/src/api/channels/channels.rs @@ -70,10 +70,11 @@ impl Channel { /// /// A `Result` that contains a `Channel` object if the request was successful, or an `ChorusLibError` if an error occurred during the request. pub async fn modify( + &mut self, modify_data: ChannelModifySchema, channel_id: Snowflake, user: &mut UserMeta, - ) -> ChorusResult { + ) -> ChorusResult<()> { let request = Client::new() .patch(format!( "{}/channels/{}/", @@ -82,12 +83,14 @@ impl Channel { )) .bearer_auth(user.token()) .body(to_string(&modify_data).unwrap()); - common::deserialize_response::( + let new_channel = common::deserialize_response::( request, user, crate::api::limits::LimitType::Channel, ) - .await + .await?; + let _ = std::mem::replace(self, new_channel); + Ok(()) } pub async fn messages( diff --git a/tests/channel.rs b/tests/channel.rs index 758b203..06a3330 100644 --- a/tests/channel.rs +++ b/tests/channel.rs @@ -29,6 +29,7 @@ async fn delete_channel() { #[tokio::test] async fn modify_channel() { let mut bundle = common::setup().await; + let channel = &mut bundle.channel; let modify_data: types::ChannelModifySchema = types::ChannelModifySchema { name: Some("beepboop".to_string()), channel_type: None, @@ -48,10 +49,10 @@ async fn modify_channel() { default_thread_rate_limit_per_user: None, video_quality_mode: None, }; - let result = Channel::modify(modify_data, bundle.channel.id, &mut bundle.user) + Channel::modify(channel, modify_data, channel.id, &mut bundle.user) .await .unwrap(); - assert_eq!(result.name, Some("beepboop".to_string())); + assert_eq!(channel.name, Some("beepboop".to_string())); let permission_override = PermissionFlags::from_vec(Vec::from([ PermissionFlags::MANAGE_CHANNELS,