Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added additional reaction controls to channel_id and message structs #2533

Merged
merged 8 commits into from
Sep 9, 2023
16 changes: 16 additions & 0 deletions src/model/channel/channel_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,22 @@ impl ChannelId {
)
.await
}
/// Deletes all of the [`Reaction`]s associated with the provided message id.
///
/// **Note**: Requires the [Manage Messages] permission.
///
/// [Manage Messages]: Permissions::MANAGE_MESSAGES
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should include an # Errors section.

#[inline]
pub async fn delete_reactions(
&self,
http: impl AsRef<Http>,
message_id: impl Into<MessageId>,
) -> Result<()> {
http.as_ref().delete_message_reactions(
self.0,
message_id.into().0,
).await
}

/// Deletes all [`Reaction`]s of the given emoji to a message within the channel.
///
Expand Down
30 changes: 30 additions & 0 deletions src/model/channel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,36 @@ impl Message {
cache_http.http().as_ref().delete_message_reactions(self.channel_id.0, self.id.0).await
}

/// Remove reaction from the message given an [`Emoji`] or unicode character
Collin-Swish marked this conversation as resolved.
Show resolved Hide resolved
///
/// **Note**: Requires the [Manage Messages] permission, _if_ the current
/// user did not perform the reaction
Collin-Swish marked this conversation as resolved.
Show resolved Hide resolved
///
/// # Errors
///
/// Returns [`Error::Http`] if the currend user did not perform the reaction,
/// and lacks permission
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Returns [`Error::Http`] if the currend user did not perform the reaction,
/// and lacks permission
/// Returns [`Error::Http`] if the current user did not perform the reaction, or lacks
/// permission.

formatting

///
/// [Manage Messages]: Permissions::MANAGE_MESSAGES
#[inline]
pub async fn delete_reaction(
self,
cache_http: impl CacheHttp,
Collin-Swish marked this conversation as resolved.
Show resolved Hide resolved
user_id: Option<UserId>,
reaction_type: impl Into<ReactionType>,
) -> Result<()> {
cache_http
.http()
.as_ref()
.delete_reaction(
self.channel_id.0,
self.id.0,
user_id.map(|uid| uid.0),
&reaction_type.into(),
)
.await
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reworked to just a wrapper around ChannelId::delete_reaction. The same goes for Message::delete_reactions, now that ChannelId::delete_reactions exists.

}

/// Deletes all of the [`Reaction`]s of a given emoji associated with the message.
///
/// **Note**: Requires the [Manage Messages] permission.
Expand Down
Loading