From 1e0783e30ef15cd7eb675f596fb609cb2b6c5a9e Mon Sep 17 00:00:00 2001 From: Flori Weber Date: Thu, 22 Jun 2023 18:56:16 +0200 Subject: [PATCH] Make Channel::modify() take &mut self --- src/api/channels/channels.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/api/channels/channels.rs b/src/api/channels/channels.rs index 08a6617..2c286dd 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,18 @@ impl Channel { )) .bearer_auth(user.token()) .body(to_string(&modify_data).unwrap()); - common::deserialize_response::( + let new_channel = match common::deserialize_response::( request, user, crate::api::limits::LimitType::Channel, ) .await + { + Ok(channel) => channel, + Err(e) => return Err(e), + }; + let _ = std::mem::replace(self, new_channel); + Ok(()) } pub async fn messages(