【发布时间】:2021-04-20 02:04:59
【问题描述】:
当你声明一个命令时,你知道那些@commands.has_permissions() 是怎么回事吧?我正在尝试创建一个显示命令检查的命令,但我不确定如何继续。到目前为止,这是我的代码:
@commands.command(aliases=['sp'])
async def showperms(self, ctx, *, command_name):
"""Shows the permissions needed for a command"""
com = self.bot.get_command(command_name)
print(com.checks)
当我为命令执行此操作时,我得到以下输出:
[<function bot_has_permissions.<locals>.predicate at 0x7fd64b5ff940>, <function has_permissions.<locals>.predicate at 0x7fd64b5ff550>]
我相信它使用 Discord 的权限整数,但几乎没有人知道如何使用这些整数。我不确定如何将其“翻译”成可以发送的内容,例如manage_messages 或administrator. 我用来测试的命令有这些检查顺便说一句:
@commands.has_permissions(manage_channels=True)
@commands.bot_has_permissions(manage_channels=True)
谢谢!!
【问题讨论】:
标签: discord.py