#[non_exhaustive]pub struct Reaction {
pub channel_id: ChannelId,
pub emoji: ReactionType,
pub message_id: MessageId,
pub user_id: Option<UserId>,
pub guild_id: Option<GuildId>,
pub member: Option<PartialMember>,
}
Expand description
An emoji reaction to a message.
Fields (Non-exhaustive)
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.channel_id: ChannelId
emoji: ReactionType
The reactive emoji used.
message_id: MessageId
The Id of the Message
that was reacted to.
user_id: Option<UserId>
The Id of the User
that sent the reaction.
Set to None
by Message::react
when cache is not available.
guild_id: Option<GuildId>
The optional Id of the Guild
where the reaction was sent.
member: Option<PartialMember>
The optional object of the member which added the reaction.
Implementations
sourceimpl Reaction
impl Reaction
sourcepub async fn channel(&self, cache_http: impl CacheHttp) -> Result<Channel>
Available on crate feature model
only.
pub async fn channel(&self, cache_http: impl CacheHttp) -> Result<Channel>
model
only.Retrieves the associated the reaction was made in.
If the cache is enabled, this will search for the already-cached channel. If not - or the channel was not found - this will perform a request over the REST API for the channel.
Requires the Read Message History permission.
Errors
Returns Error::Http
if the current user lacks permission,
or if the channel no longer exists.
sourcepub async fn delete(&self, cache_http: impl CacheHttp) -> Result<()>
Available on crate feature model
only.
pub async fn delete(&self, cache_http: impl CacheHttp) -> Result<()>
model
only.Deletes the reaction, but only if the current user is the user who made the reaction or has permission to.
Requires the Manage Messages permission, if the current user did not perform the reaction.
Errors
If the cache
is enabled, then returns a
ModelError::InvalidPermissions
if the current user does not have
the required permissions.
Otherwise returns Error::Http
if the current user lacks permission.
sourcepub async fn delete_all(&self, cache_http: impl CacheHttp) -> Result<()>
Available on crate feature model
only.
pub async fn delete_all(&self, cache_http: impl CacheHttp) -> Result<()>
model
only.Deletes all reactions from the message with this emoji.
Requires the Manage Messages permission
Errors
If the cache
is enabled, then returns a
ModelError::InvalidPermissions
if the current user does not have
the required permissions.
Otherwise returns Error::Http
if the current user lacks permission.
sourcepub async fn message(&self, http: impl AsRef<Http>) -> Result<Message>
Available on crate feature model
only.
pub async fn message(&self, http: impl AsRef<Http>) -> Result<Message>
model
only.Retrieves the Message
associated with this reaction.
Requires the Read Message History permission.
Note: This will send a request to the REST API. Prefer maintaining your own message cache or otherwise having the message available if possible.
Errors
Returns Error::Http
if the current user lacks permission to
read message history, or if the message was deleted.
sourcepub async fn user(&self, cache_http: impl CacheHttp) -> Result<User>
Available on crate feature model
only.
pub async fn user(&self, cache_http: impl CacheHttp) -> Result<User>
model
only.Retrieves the user that made the reaction.
If the cache is enabled, this will search for the already-cached user. If not - or the user was not found - this will perform a request over the REST API for the user.
Errors
Returns Error::Http
if the user that made the reaction is unable to be
retrieved from the API.
sourcepub async fn users<R, U>(
&self,
http: impl AsRef<Http>,
reaction_type: R,
limit: Option<u8>,
after: Option<U>
) -> Result<Vec<User>> where
R: Into<ReactionType>,
U: Into<UserId>,
Available on crate feature model
only.
pub async fn users<R, U>(
&self,
http: impl AsRef<Http>,
reaction_type: R,
limit: Option<u8>,
after: Option<U>
) -> Result<Vec<User>> where
R: Into<ReactionType>,
U: Into<UserId>,
model
only.Retrieves the list of User
s who have reacted to a Message
with a
certain Emoji
.
The default limit
is 50
- specify otherwise to receive a different
maximum number of users. The maximum that may be retrieve at a time is
100
, if a greater number is provided then it is automatically reduced.
The optional after
attribute is to retrieve the users after a certain
user. This is useful for pagination.
Requires the Read Message History permission.
Note: This will send a request to the REST API.
Errors
Returns a ModelError::InvalidPermissions
if the current user does
not have the required permissions.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Reaction
impl<'de> Deserialize<'de> for Reaction
sourcefn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Reaction
impl Send for Reaction
impl Sync for Reaction
impl Unpin for Reaction
impl UnwindSafe for Reaction
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more