arguments passed to Message::react
#1854
-
The signature of the function is: pub async fn react(
&self,
cache_http: impl CacheHttp,
reaction_type: impl Into<ReactionType>,
) -> Result<Reaction> What do you pass into the reaction_type parameter? Please explain with an example |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The job of
As an example, here is how you would react to a message with a Unicode emoji: let ctx: &Context = ...;
let msg: &Message = ...;
msg.react(ctx, '😄').await?; And here's with a custom emoji (assuming use serenity::model::id::EmojiId;
use serenity::model::misc::EmojiIdentifier;
let ctx: &Context = ...;
let msg: &Message = ...;
msg.react(ctx, EmojiIdentifier { animated: false, id: EmojiId(1234), name: "foo".to_string() }).await?; Of course, this doesn't stop you from using let ctx: &Context = ...;
let msg: &Message = ...;
msg.react(ctx, ReactionType::Unicode("🐱".to_string())).await?; |
Beta Was this translation helpful? Give feedback.
The job of
ReactionType
is to handle two kinds of emoji types:<a?:id:name>
(the?
means that "a" may be omitted). Custom emojis are just regular static (jpg, png) or animated (gif) images.Message::react
uses theInto
trait to allow users to pass emoji data into the function without having to…