[英]How can I make some commands only work if you have a specific permission with python?
I have a command "$clear" which clears a specific number of messages.我有一个命令“$clear”,它清除特定数量的消息。 I do not know how to make this command work if you only have the permission "administrator".
如果您只有“管理员”权限,我不知道如何使此命令起作用。 If anyone knows how to do this that would help me a lot, and here's my code:
如果有人知道如何做到这一点,那将对我有很大帮助,这是我的代码:
async def clear(message, limit:int):
await message.channel.purge(limit=limit)
await message.channel.send(f'{limit} messages have been cleared.')
Using the @commands.has_permissions(administrator=True)
decorator will only allow administrators to run the given command.使用
@commands.has_permissions(administrator=True)
装饰器将只允许管理员运行给定的命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.