permissions.py 文件源码

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

项目:discord_chat_bot 作者: chromaticity 项目源码 文件源码
def for_user(self, user):
        """
        Returns the first PermissionGroup a user belongs to
        :param user: A discord User or Member object
        """

        for group in self.groups:
            if user.id in group.user_list:
                return group

        # The only way I could search for roles is if I add a `server=None` param and pass that too
        if type(user) == discord_User:
            return self.default_group

        # We loop again so that we don't return a role based group before we find an assigned one
        for group in self.groups:
            for role in user.roles:
                if role.id in group.granted_to_roles:
                    return group

        return self.default_group
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号