我刚刚创建了一个自定义帮助命令,但是我不明白如何显示运行该命令所需的权限以及命令的冷却时间,尝试使用此操作但不起作用
async def cmdhelp(self, ctx, command):
params = []
for key, value in command.params.items():
if key not in ("self", "ctx"):
params.append(f"[{key}]" if "NoneType" in str(value) else f"<{key}>")
params = " ".join(params)
embed = discord.Embed(title=f"Help for {command}",
colour=ctx.author.colour)
embed.add_field(name="Description:", value=command.help, inline=False)
embed.add_field(name="Usage:", value=f"`{command} {params}`", inline=False)
if not command.aliases:
embed.add_field(name="Aliases:", value="None", inline=False)
else:
embed.add_field(name="Aliases:", value=", ".join(command.aliases))
embed.add_field(name="Permission Required:", value=f"{command.check}")
embed.add_field(name="Cooldown:", value=command.cooldown)
await ctx.send(embed=embed)
我尝试使用commands.has_permissions()
它给了我这个<function check.<locals>.decorator at 0x04FDADA8>
所以我试着做这段代码,但是没用
if commands.has_permissions() == "<function check.<locals>.decorator at 0x04FDABF8>":
embed.add_field(name="Permission Required:", value=f"None", inline=False)
else:
embed.add_field(name="Permission Required:", value=f"Unban", inline=False)
await ctx.send(embed=embed)
答案 0 :(得分:0)
我认为您可能只需要手动将所需的权限分配给命令。我以前从未见过这样的东西:/,对不起,我帮不了你:<< / p>