aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-05-28 10:08:09 -0700
committerZeyla Hellyer <[email protected]>2017-05-28 10:09:12 -0700
commit2afab7c6eb828e491721e15f11a76ae36e34796d (patch)
tree85f54eedb956a8c35852f9721314041b7b221482 /src/model
parentAdd CurrentUser::invite_url method (diff)
downloadserenity-2afab7c6eb828e491721e15f11a76ae36e34796d.tar.xz
serenity-2afab7c6eb828e491721e15f11a76ae36e34796d.zip
impl From<char> for ReactionType
This can be used as a helpful shortcut for reactions.
Diffstat (limited to 'src/model')
-rw-r--r--src/model/channel/reaction.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/model/channel/reaction.rs b/src/model/channel/reaction.rs
index fbc02ad..a9d17fa 100644
--- a/src/model/channel/reaction.rs
+++ b/src/model/channel/reaction.rs
@@ -241,6 +241,33 @@ impl ReactionType {
}
}
+impl From<char> for ReactionType {
+ /// Creates a `ReactionType` from a `char`.
+ ///
+ /// # Examples
+ ///
+ /// Reacting to a message with an apple:
+ ///
+ /// ```rust,no_run
+ /// # use serenity::model::ChannelId;
+ /// # use std::error::Error;
+ /// #
+ /// # fn try_main() -> Result<(), Box<Error>> {
+ /// # let message = ChannelId(0).get_message(0)?;
+ /// #
+ /// message.react('🍎')?;
+ /// # Ok(())
+ /// # }
+ /// #
+ /// # fn main() {
+ /// # try_main().unwrap();
+ /// # }
+ /// ```
+ fn from(ch: char) -> ReactionType {
+ ReactionType::Unicode(ch.to_string())
+ }
+}
+
impl From<Emoji> for ReactionType {
fn from(emoji: Emoji) -> ReactionType {
ReactionType::Custom {