modlog.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:dogbot 作者: slice 项目源码 文件源码
def get_responsible(self, guild: discord.Guild, action: str, *, target: discord.Member=None) -> discord.AuditLogEntry:
        """
        Checks the audit log for recent action performed on some user.

        :param guild: The :class:`discord.Guild` to look at.
        :param action: The name of the :class:`discord.AuditLogAction` attribute to check for.
        :param target: The targeted user to check for.
        :returns: The audit log entry.
        """
        try:
            # get the audit logs for the action specified
            entries = await guild.audit_logs(limit=1, action=getattr(discord.AuditLogAction, action)).flatten()

            # only check for entries performed on target, and happened in the last 2 seconds
            def check(entry):
                created_ago = (datetime.datetime.utcnow() - entry.created_at).total_seconds()
                return (entry.target == target if target else True) and created_ago <= 2

            return discord.utils.find(check, entries)
        except discord.Forbidden:
            pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号