discord.ext.command.errors.CommandInvokeError: 命令引发异常: 属性错误: 'NoneType'对象没有属性'qualified_name'



我正在为我的机器人制作一个自定义帮助命令,这是我的代码。

class customhelpcommand(commands.HelpCommand):
def __init__(self):
super().__init__()

async def send_bot_help(self, mapping):
for cog in mapping:
await self.get_destination().send(f"{cog.qualified_name}: {[command.name for command in mapping(cog)]}")

async def send_cog_help(self, cog):
await self.get_destination().send(f"{cog.qualified_name}: {[command.name for command in cog.get_commands()]}")

mapping中的一些齿轮可能是None。因此,您可以简单地检查它:

async def send_bot_help(self, mapping):
for cog in mapping:
if cog is not None:
await self.get_destination().send(f"{cog.qualified_name}: {[command.name for command in mapping(cog)]}")

最新更新