diff options
| author | Rapptz <[email protected]> | 2017-04-21 17:31:13 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-04-21 17:32:09 -0400 |
| commit | b05d8790fc66e1ec1c4722541fd2211211e22185 (patch) | |
| tree | d240ad1c2c17cc8cf380dfd9544e7dd3cc763914 | |
| parent | Support for new member message types. (diff) | |
| download | discord.py-b05d8790fc66e1ec1c4722541fd2211211e22185.tar.xz discord.py-b05d8790fc66e1ec1c4722541fd2211211e22185.zip | |
Allow using Reaction objects while adding or removing reactions.
| -rw-r--r-- | discord/message.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/discord/message.py b/discord/message.py index 4703c1dd..79aa29c2 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) |