示例#1
0
    async def get_who_reacted(self, emoji: 'typing.Union[dt_emoji.Emoji, str]') \
            -> 'typing.List[typing.Union[dt_user.User, dt_member.Member]]':
        """
        Fetches who reacted to this message.

        :param emoji: The emoji to check.
        :return: A list of either :class:`~.Member` or :class:`~.User` that reacted to this message.
        """
        if isinstance(emoji, dt_emoji.Emoji):
            emoji = "{}:{}".format(emoji.name, emoji.id)

        reactions = await self._bot.http.get_reaction_users(self.channel.id, self.id, emoji)
        result = []

        for user in reactions:
            member_id = int(user.get("id"))
            if self.guild is None:
                result.append(dt_user.User(self._bot, **user))
            else:
                member = self.guild.members.get(member_id)
                if not member:
                    result.append(dt_user.User(self._bot, **user))
                else:
                    result.append(member)

        return result
示例#2
0
 def user(self) -> 'dt_user.User':
     """
     :return: The underlying :class:`.User` for this member.
     """
     try:
         return self._bot.state._users[self.id]
     except KeyError:
         # don't go through make_user as it'll cache it
         return dt_user.User(self._bot, **self._user_data)
示例#3
0
    async def get_bans(self) -> 'typing.List[dt_user.User]':
        """
        Gets the bans for this guild.

        :return: A list of :class:`.User` objects, one for each ban.
        """
        if not self.me.guild_permissions.ban_members:
            raise PermissionsError("ban_members")

        bans = await self._bot.http.get_bans(self.id)
        users = []

        for user_data in bans:
            # TODO: Audit log stuff, if it ever comes out.
            user_data = user_data.get("user", None)
            users.append(dt_user.User(self._bot, **user_data))

        return users