Alcatraz b312
Alcatraz b312

Reputation: 259

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

I am making a custom help command for my bot and here is my code.

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

Upvotes: 3

Views: 817

Answers (1)

Ratery
Ratery

Reputation: 2917

Some cogs in your mapping might be None. Therefore you can simply check it:

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

Upvotes: 3

Related Questions