我正在为我的机器人制作一个自定义帮助命令,这是我的代码。
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)]}")