Browse Source

Allow PartialReactionEmoji in add_reaction and remove_reaction.

pull/620/head
Rapptz 8 years ago
parent
commit
8caa088d25
  1. 5
      discord/emoji.py
  2. 10
      discord/message.py

5
discord/emoji.py

@ -80,6 +80,11 @@ class PartialReactionEmoji(namedtuple('PartialReactionEmoji', 'name id')):
"""Checks if this is a Unicode emoji."""
return self.id is None
def _as_reaction(self):
if self.id is None:
return self.name
return ':%s:%s' % (self.name, self.id)
class Emoji(Hashable):
"""Represents a custom emoji.

10
discord/message.py

@ -29,7 +29,7 @@ import re
from . import utils
from .reaction import Reaction
from .emoji import Emoji
from .emoji import Emoji, PartialReactionEmoji
from .calls import CallMessage
from .enums import MessageType, try_enum
from .errors import InvalidArgument, ClientException, HTTPException, NotFound
@ -593,7 +593,7 @@ class Message:
Parameters
------------
emoji: Union[:class:`Emoji`, :class:`Reaction`, str]
emoji: Union[:class:`Emoji`, :class:`Reaction`, :class:`PartialReactionEmoji`, str]
The emoji to react with.
Raises
@ -613,6 +613,8 @@ class Message:
if isinstance(emoji, Emoji):
emoji = '%s:%s' % (emoji.name, emoji.id)
elif isinstance(emoji, PartialReactionEmoji):
emoji = emoji._as_reaction()
elif isinstance(emoji, str):
pass # this is okay
else:
@ -636,7 +638,7 @@ class Message:
Parameters
------------
emoji: Union[:class:`Emoji`, :class:`Reaction`, str]
emoji: Union[:class:`Emoji`, :class:`Reaction`, :class:`PartialReactionEmoji`, str]
The emoji to remove.
member: :class:`abc.Snowflake`
The member for which to remove the reaction.
@ -658,6 +660,8 @@ class Message:
if isinstance(emoji, Emoji):
emoji = '%s:%s' % (emoji.name, emoji.id)
elif isinstance(emoji, PartialReactionEmoji):
emoji = emoji._as_reaction()
elif isinstance(emoji, str):
pass # this is okay
else:

Loading…
Cancel
Save