3

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()]}")
2
  • it gives the error : AttributeError: 'NoneType' object has no attribute 'qualified_name' Commented Dec 24, 2021 at 16:52
  • you first check the object (e.g. if cog is not None: ...) then you should move further. Commented Dec 24, 2021 at 17:01

1 Answer 1

3

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)]}")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.