Skip to content

AttributeError: 'NoneType' object has no attribute 'qualified_name' #769

@ghost

Description

Summary

AttributeError: NoneType object has no attribute qualified_name

Reproduction Steps

Build a help command and attempt to map the commands inside a cog. For example:

import discord

from env import BLUE, PREFIX
from discord.ext import commands

class Help(commands.Cog):
    def __init__(self, client):
        self.client = client

class CustomHelp(commands.HelpCommand):
    async def send_bot_help(self, mapping):
        embed = discord.Embed(title='TITLE_HERE', description='DESCRIPTION_HERE', color=BLUE)
        for cog, cmds in mapping.items():
            name = cog.qualified_name
            embed.add_field(name = name, value = f"{len(cmds)} commands")
            embed.set_thumbnail(url='IMAGE_URL_HERE')

        channel = self.get_destination()
        await channel.send(embed=embed)

client.help_command = CustomHelp()

Minimal Reproducible Code

AttributeError: 'NoneType' object has no attribute 'qualified_name'

Expected Results

Should display a help embed with a list of cogs and their commands.

Actual Results

Errors out with the following error:

AttributeError: 'NoneType' object has no attribute 'qualified_name'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/home/almalinux/Faestine/cogs/events.py", line 43, in on_command_error
    raise error
  File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'qualified_name'

Intents

None

System Information

  • Python v3.6.8-final
  • discord.py v1.7.3-final
  • aiohttp v3.7.4.post0
  • system info: Linux 4.18.0-348.2.1.el8_5.x86_64 Update README.rst #1 SMP Mon Nov 15 09:17:08 EST 2021

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

This error seems to have also existed in the old discord.py builds as well and may have been carried over: Rapptz/discord.py#2029

Metadata

Metadata

Assignees

No one assigned

    Labels

    unconfirmed bugA bug report that needs triaging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions