Add method to remove own reaction

This commit is contained in:
bitfl0wer 2023-06-04 14:39:22 +02:00
parent 7a811e1792
commit 0a106d2e1d
1 changed files with 39 additions and 0 deletions

View File

@ -180,6 +180,45 @@ impl ReactionMeta {
.await .await
} }
/**
Delete a reaction the current user has made for the message.
# Arguments
* `emoji` - A string slice containing the emoji to delete. The `emoji` must be URL Encoded or
the request will fail with 10014: Unknown Emoji. To use custom emoji, you must encode it in the
format name:id with the emoji name and emoji id.
* `user` - A mutable reference to a [`UserMeta`] instance.
# Returns
A `Result` containing a [`reqwest::Response`] or a [`crate::errors::InstanceServerError`].
Returns a 204 empty response on success.
Fires a `Message Reaction Remove` Gateway event.
*/
pub async fn remove(
&self,
emoji: &str,
user: &mut UserMeta,
) -> Result<reqwest::Response, crate::errors::InstanceServerError> {
let mut belongs_to = user.belongs_to.borrow_mut();
let url = format!(
"{}/channels/{}/messages/{}/reactions/{}/@me/",
belongs_to.urls.get_api(),
self.channel_id,
self.message_id,
emoji
);
let request = Client::new().delete(url).bearer_auth(user.token());
LimitedRequester::new()
.await
.send_request(
request,
crate::api::limits::LimitType::Channel,
&mut belongs_to.limits,
&mut user.limits,
)
.await
}
/** /**
Delete a user's reaction to a message. Delete a user's reaction to a message.