gpt4 book ai didi

python - discord.ext.commands.errors.CommandInvokeError : Command raised an exception: AttributeError: 'NoneType' object has no attribute 'qualified_name'

转载 作者:行者123 更新时间:2023-12-05 03:32:22 35 4
gpt4 key购买 nike

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

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()]}")

最佳答案

您的映射 中的某些齿轮可能是。因此你可以简单地检查它:

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)]}")

关于python - discord.ext.commands.errors.CommandInvokeError : Command raised an exception: AttributeError: 'NoneType' object has no attribute 'qualified_name' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70475058/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com