Enum serenity::model::channel::ReactionType [−][src]
#[non_exhaustive]
pub enum ReactionType {
Custom {
animated: bool,
id: EmojiId,
name: Option<String>,
},
Unicode(String),
}
Expand description
The type of a Reaction
sent.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Custom
Fields
animated: bool
Whether the emoji is animated.
Unicode(String)
Tuple Fields
0: String
A reaction with a twemoji.
Implementations
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.
Helper function to allow testing equality of unicode emojis without having to perform any allocation. Will always return false if the reaction was not a unicode reaction.
Helper function to allow comparing unicode emojis without having to perform any allocation. Will return None if the reaction was not a unicode reaction.
Trait Implementations
Deserialize this value from the given Serde deserializer. Read more
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.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Creates a ReactionType
from a char
.
Examples
Reacting to a message with an apple:
message.react(ctx, '🍎').await?;
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
type Error = ReactionConversionError
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 std::convert::TryInto;
use std::fmt::Debug;
use serenity::model::channel::ReactionType;
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 std::convert::TryFrom;
use serenity::model::channel::ReactionType;
use serenity::model::id::EmojiId;
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);
Auto Trait Implementations
impl RefUnwindSafe for ReactionType
impl Send for ReactionType
impl Sync for ReactionType
impl Unpin for ReactionType
impl UnwindSafe for ReactionType
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more