utils.py 文件源码

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

项目:pcbot 作者: pckv 项目源码 文件源码
def role(*roles: str):
    """ Decorator that runs the command only if the author has the specified Roles.
    roles must be a string representing a role's name. 

    NOTE: this function is deprecated. Use the command 'roles' attribute instead.
    """
    def decorator(func):
        @wraps(func)
        async def wrapped(message: discord.Message, *args, **kwargs):
            member_roles = [r.name for r in message.author.roles[1:]]

            if any(r in member_roles for r in roles):
                await func(message, *args, **kwargs)

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


问题


面经


文章

微信
公众号

扫码关注公众号