#[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
Implementations§
Source§impl ReactionType
impl ReactionType
Sourcepub fn as_data(&self) -> String
pub fn as_data(&self) -> String
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.
Sourcepub fn unicode_eq(&self, other: &str) -> bool
pub fn unicode_eq(&self, other: &str) -> bool
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.
Sourcepub fn unicode_partial_cmp(&self, other: &str) -> Option<Ordering>
pub fn unicode_partial_cmp(&self, other: &str) -> Option<Ordering>
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§
Source§impl Clone for ReactionType
impl Clone for ReactionType
Source§fn clone(&self) -> ReactionType
fn clone(&self) -> ReactionType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ReactionType
impl Debug for ReactionType
Source§impl<'de> Deserialize<'de> for ReactionType
impl<'de> Deserialize<'de> for ReactionType
Source§fn deserialize<D: Deserializer<'de>>(
deserializer: D,
) -> StdResult<Self, D::Error>
fn deserialize<D: Deserializer<'de>>( deserializer: D, ) -> StdResult<Self, D::Error>
Source§impl Display for ReactionType
impl Display for ReactionType
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
Source§impl From<Emoji> for ReactionType
impl From<Emoji> for ReactionType
Source§fn from(emoji: Emoji) -> ReactionType
fn from(emoji: Emoji) -> ReactionType
Source§impl From<EmojiId> for ReactionType
impl From<EmojiId> for ReactionType
Source§fn from(emoji_id: EmojiId) -> ReactionType
fn from(emoji_id: EmojiId) -> ReactionType
Source§impl From<EmojiIdentifier> for ReactionType
impl From<EmojiIdentifier> for ReactionType
Source§fn from(emoji_id: EmojiIdentifier) -> ReactionType
fn from(emoji_id: EmojiIdentifier) -> ReactionType
Source§impl From<char> for ReactionType
impl From<char> for ReactionType
Source§fn from(ch: char) -> ReactionType
fn from(ch: char) -> ReactionType
Creates a ReactionType
from a char
.
§Examples
Reacting to a message with an apple:
message.react(ctx, '🍎').await?;
Source§impl FromStr for ReactionType
impl FromStr for ReactionType
Source§impl Hash for ReactionType
impl Hash for ReactionType
Source§impl PartialEq for ReactionType
impl PartialEq for ReactionType
Source§impl Serialize for ReactionType
impl Serialize for ReactionType
Source§impl TryFrom<&str> for ReactionType
impl TryFrom<&str> for ReactionType
Source§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 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::new(600404340292059257),
name: Some("customemoji".to_string()),
};
assert_eq!(reaction, reaction2);
Source§impl TryFrom<String> for ReactionType
impl TryFrom<String> for ReactionType
impl Eq for ReactionType
impl StructuralPartialEq for ReactionType
Auto Trait Implementations§
impl Freeze for ReactionType
impl RefUnwindSafe for ReactionType
impl Send for ReactionType
impl Sync for ReactionType
impl Unpin for ReactionType
impl UnwindSafe for ReactionType
Blanket Implementations§
Source§impl<T> ArgumentConvert for Twhere
T: FromStr,
impl<T> ArgumentConvert for Twhere
T: FromStr,
Source§fn convert<'life0, 'async_trait>(
__arg0: impl CacheHttp + 'async_trait,
__arg1: Option<GuildId>,
__arg2: Option<ChannelId>,
s: &'life0 str,
) -> Pin<Box<dyn Future<Output = Result<T, <T as ArgumentConvert>::Err>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
fn convert<'life0, 'async_trait>(
__arg0: impl CacheHttp + 'async_trait,
__arg1: Option<GuildId>,
__arg2: Option<ChannelId>,
s: &'life0 str,
) -> Pin<Box<dyn Future<Output = Result<T, <T as ArgumentConvert>::Err>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
s
as a command parameter of this type.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.