[][src]Enum serenity::model::channel::ReactionType

#[non_exhaustive]pub enum ReactionType {
    Custom {
        animated: bool,
        id: EmojiId,
        name: Option<String>,
    },
    Unicode(String),
}

The type of a Reaction sent.

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Custom

A reaction with a Guilds custom Emoji, which is unique to the guild.

Fields of Custom

animated: bool

Whether the emoji is animated.

id: EmojiId

The Id of the custom Emoji.

name: Option<String>

The name of the custom emoji. This is primarily used for decoration and distinguishing the emoji client-side.

Unicode(String)

A reaction with a twemoji.

Implementations

impl ReactionType[src]

pub fn as_data(&self) -> String[src]

Creates a data-esque display of the type. This is not very useful for displaying, as the primary client can not render it, but can be useful for debugging.

Note: This is mainly for use internally. There is otherwise most likely little use for it.

Trait Implementations

impl Clone for ReactionType[src]

impl Debug for ReactionType[src]

impl<'de> Deserialize<'de> for ReactionType[src]

impl Display for ReactionType[src]

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult[src]

Formats the reaction type, displaying the associated emoji in a way that clients can understand.

If the type is a custom emoji, then refer to the documentation for emoji's formatter on how this is displayed. Otherwise, if the type is a unicode, then the inner unicode is displayed.

impl Eq for ReactionType[src]

impl From<Emoji> for ReactionType[src]

impl From<EmojiId> for ReactionType[src]

impl From<EmojiIdentifier> for ReactionType[src]

impl From<char> for ReactionType[src]

fn from(ch: char) -> ReactionType[src]

Creates a ReactionType from a char.

Examples

Reacting to a message with an apple:

message.react(ctx, '🍎').await?;

impl FromStr for ReactionType[src]

type Err = ReactionConversionError

The associated error which can be returned from parsing.

impl Hash for ReactionType[src]

impl PartialEq<ReactionType> for ReactionType[src]

impl Serialize for ReactionType[src]

impl StructuralEq for ReactionType[src]

impl StructuralPartialEq for ReactionType[src]

impl<'a> TryFrom<&'a str> for ReactionType[src]

type Error = ReactionConversionError

Creates a ReactionType from a string slice.

Examples

Creating a ReactionType from a 🍎, modeling a similar API as the rest of the library:

use serenity::model::channel::ReactionType;
use std::convert::TryInto;
use std::fmt::Debug;

fn foo<R: TryInto<ReactionType>>(bar: R)
    where R::Error: Debug
{
    println!("{:?}", bar.try_into().unwrap());
}

foo("🍎");

Creating a ReactionType from a custom emoji argument in the following format:

use serenity::model::channel::ReactionType;
use serenity::model::id::EmojiId;
use std::convert::TryFrom;

let emoji_string = "<:customemoji:600404340292059257>";
let reaction = ReactionType::try_from(emoji_string).unwrap();
let reaction2 = ReactionType::Custom {
    animated: false,
    id: EmojiId(600404340292059257),
    name: Some("customemoji".to_string()),
};

assert_eq!(reaction, reaction2);

impl TryFrom<String> for ReactionType[src]

type Error = ReactionConversionError

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<F> FromStrAndCache for F where
    F: FromStr
[src]

type Err = <F as FromStr>::Err

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

impl<T> WithSubscriber for T[src]