Esempio n. 1
0
    async def parse_message_reaction_add(self, data, old):
        emoji = PartialEmoji.with_state(
            self,
            id=utils._get_as_snowflake(data["emoji"], "id"),
            animated=data["emoji"].get("animated", False),
            name=data["emoji"]["name"],
        )

        raw = RawReactionActionEvent(data, emoji, "REACTION_ADD")

        member = data.get("member")
        if member:
            guild = await self._get_guild(raw.guild_id)
            if guild:
                raw.member = Member(guild=guild, state=self, data=member)

        self.dispatch("raw_reaction_add", raw)

        message = await self._get_message(raw.message_id)
        if message:
            reaction = Reaction(message=message,
                                data=data,
                                emoji=await self._upgrade_partial_emoji(emoji))
            user = raw.member or await self._get_reaction_user(
                message.channel, raw.user_id)

            if user:
                self.dispatch("reaction_add", reaction, user)
Esempio n. 2
0
 async def parse_message_reaction_remove_emoji(self, data, old):
     emoji = PartialEmoji.with_state(
         self,
         id=utils._get_as_snowflake(data["emoji"], "id"),
         name=data["emoji"]["name"],
     )
     raw = RawReactionClearEmojiEvent(data, emoji)
     self.dispatch("raw_reaction_clear_emoji", raw)
     message = await self._get_message(raw.message_id)
     if message:
         reaction = Reaction(message=message,
                             data=data,
                             emoji=await self._upgrade_partial_emoji(emoji))
         self.dispatch("reaction_clear_emoji", reaction)
Esempio n. 3
0
 def __init__(self, state, data):
     self._state = state
     self.id = int(data['id'])
     self.name = data['name']
     self.features = data.get('features', [])
     self.icon = data.get('icon')
     self.approximate_presence_count = data.get(
         'approximate_presence_count')
     self.approximate_member_count = data.get('approximate_member_count')
     self.banner = data.get('banner')
     self.splash = data.get('splash')
     self.discovery_splash = data.get('discovery_splash')
     self.description = data.get('description')
     self.emojis = tuple(
         map(lambda d: PartialEmoji.from_dict(d), data.get('emojis', [])))
Esempio n. 4
0
 async def parse_message_reaction_remove(self, data, old):
     emoji = PartialEmoji.with_state(
         self,
         id=utils._get_as_snowflake(data["emoji"], "id"),
         name=data["emoji"]["name"],
     )
     raw = RawReactionActionEvent(data, emoji, "REACTION_REMOVE")
     self.dispatch("raw_reaction_remove", raw)
     message = await self._get_message(raw.message_id)
     if message:
         reaction = Reaction(message=message,
                             data=data,
                             emoji=await self._upgrade_partial_emoji(emoji))
         user = await self._get_reaction_user(message.channel, raw.user_id)
         if user:
             self.dispatch("reaction_remove", reaction, user)