Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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()]}")
like image 333
Alcatraz b312 Avatar asked Dec 21 '25 08:12

Alcatraz b312


1 Answers

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)]}")
like image 191
Ratery Avatar answered Dec 22 '25 22:12

Ratery



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!