utils.py 文件源码

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

项目:pcbot 作者: pckv 项目源码 文件源码
def permission(*perms: str):
    """ Decorator that runs the command only if the author has the specified permissions.
    perms must be a string matching any property of discord.Permissions.

    NOTE: this function is deprecated. Use the command 'permissions' attribute instead.
    """
    def decorator(func):
        @wraps(func)
        async def wrapped(message: discord.Message, *args, **kwargs):
            member_perms = message.author.permissions_in(message.channel)

            if all(getattr(member_perms, perm, False) for perm in perms):
                await func(message, *args, **kwargs)

        return wrapped
    return decorator
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号