From b05d8790fc66e1ec1c4722541fd2211211e22185 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Fri, 21 Apr 2017 17:31:13 -0400 Subject: [PATCH] Allow using Reaction objects while adding or removing reactions. --- discord/message.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/discord/message.py b/discord/message.py index 4703c1ddd..79aa29c2a 100644 --- a/discord/message.py +++ b/discord/message.py @@ -520,7 +520,7 @@ class Message: Parameters ------------ - emoji: :class:`Emoji` or str + emoji: Union[:class:`Emoji`, :class:`Reaction`, str] The emoji to react with. Raises @@ -535,12 +535,14 @@ class Message: The emoji parameter is invalid. """ - if isinstance(emoji, Emoji): + if isinstance(emoji, Reaction): + emoji = str(emoji.emoji) + elif isinstance(emoji, Emoji): emoji = '%s:%s' % (emoji.name, emoji.id) elif isinstance(emoji, str): pass # this is okay else: - raise InvalidArgument('emoji argument must be a string or discord.Emoji') + raise InvalidArgument('emoji argument must be str, Emoji, or Reaction not {.__class__.__name__}.'.format(emoji)) yield from self._state.http.add_reaction(self.id, self.channel.id, emoji) @@ -560,7 +562,7 @@ class Message: Parameters ------------ - emoji: :class:`Emoji` or str + emoji: Union[:class:`Emoji`, :class:`Reaction`, str] The emoji to remove. member: :class:`abc.Snowflake` The member for which to remove the reaction. @@ -577,12 +579,14 @@ class Message: The emoji parameter is invalid. """ - if isinstance(emoji, Emoji): + if isinstance(emoji, Reaction): + emoji = str(emoji.emoji) + elif isinstance(emoji, Emoji): emoji = '%s:%s' % (emoji.name, emoji.id) elif isinstance(emoji, str): pass # this is okay else: - raise InvalidArgument('emoji argument must be a string or discord.Emoji') + raise InvalidArgument('emoji argument must be str, Emoji, or Reaction not {.__class__.__name__}.'.format(emoji)) yield from self._state.http.remove_reaction(self.id, self.channel.id, emoji, member.id)