Make Channel::modify() take &mut self

This commit is contained in:
Flori Weber 2023-06-22 18:56:16 +02:00
parent 4b31fb4ec7
commit 1e0783e30e
No known key found for this signature in database
GPG Key ID: 0ACD574FCF5226CF
1 changed files with 9 additions and 2 deletions

View File

@ -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. /// 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( pub async fn modify(
&mut self,
modify_data: ChannelModifySchema, modify_data: ChannelModifySchema,
channel_id: Snowflake, channel_id: Snowflake,
user: &mut UserMeta, user: &mut UserMeta,
) -> ChorusResult<Channel> { ) -> ChorusResult<()> {
let request = Client::new() let request = Client::new()
.patch(format!( .patch(format!(
"{}/channels/{}/", "{}/channels/{}/",
@ -82,12 +83,18 @@ impl Channel {
)) ))
.bearer_auth(user.token()) .bearer_auth(user.token())
.body(to_string(&modify_data).unwrap()); .body(to_string(&modify_data).unwrap());
common::deserialize_response::<Channel>( let new_channel = match common::deserialize_response::<Channel>(
request, request,
user, user,
crate::api::limits::LimitType::Channel, crate::api::limits::LimitType::Channel,
) )
.await .await
{
Ok(channel) => channel,
Err(e) => return Err(e),
};
let _ = std::mem::replace(self, new_channel);
Ok(())
} }
pub async fn messages( pub async fn messages(