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
评论列表
文章目录