#[non_exhaustive]
pub struct Reaction { pub user_id: Option<UserId>, pub channel_id: ChannelId, pub message_id: MessageId, pub guild_id: Option<GuildId>, pub member: Option<Member>, pub emoji: ReactionType, }
Expand description

An emoji reaction to a message.

Discord docs.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§user_id: Option<UserId>

The Id of the User that sent the reaction.

Always present when received from gateway. Set to None by Message::react when cache is not available.

§channel_id: ChannelId

The Channel of the associated Message.

§message_id: MessageId

The Id of the Message that was reacted to.

§guild_id: Option<GuildId>

The optional Id of the Guild where the reaction was sent.

§member: Option<Member>

The optional object of the member which added the reaction.

§emoji: ReactionType

The reactive emoji used.

Implementations§

source§

impl<'de> Reaction

source

pub fn deserialize<__D>(__deserializer: __D) -> Result<Reaction, __D::Error>
where __D: Deserializer<'de>,

source§

impl Reaction

source

pub fn serialize<__S>( __self: &Reaction, __serializer: __S ) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

source§

impl Reaction

source

pub async fn channel(&self, cache_http: impl CacheHttp) -> Result<Channel>

Available on crate feature 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.

source

pub async fn delete(&self, cache_http: impl CacheHttp) -> Result<()>

Available on crate feature 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.

source

pub async fn delete_all(&self, cache_http: impl CacheHttp) -> Result<()>

Available on crate feature 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.

source

pub async fn message(&self, cache_http: impl CacheHttp) -> Result<Message>

Available on crate feature model only.

Retrieves the Message associated with this reaction.

Requires the Read Message History permission.

§Errors

Returns Error::Http if the current user lacks permission to read message history, or if the message was deleted.

source

pub async fn user(&self, cache_http: impl CacheHttp) -> Result<User>

Available on crate feature 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.

source

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>,

Available on crate feature model only.

Retrieves the list of Users 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§

source§

impl Clone for Reaction

source§

fn clone(&self) -> Reaction

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Reaction

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Reaction

source§

fn deserialize<D: Deserializer<'de>>( deserializer: D ) -> StdResult<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Reaction

source§

fn serialize<S: Serializer>(&self, serializer: S) -> StdResult<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneDebuggableStorage for T

source§

impl<T> CloneableStorage for T
where T: Any + Send + Sync + Clone,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DebuggableStorage for T
where T: Any + Send + Sync + Debug,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,