Skip to content

[BUG] Context is missing command attribute in the on_component event #1133

@Catalyst4222

Description

@Catalyst4222

Describe the bug.

Taken from #AttributeError 'NoneType' object has no attribute 'name' in the help forum

In the on_command event, there is a possibility that ctx.command is None instead of the associated Command instance. This is due to a race condition where some attribute processing for Context is done when the command is being invoked. This issue likely applies to other attributes as well, though that has not been tested yet

A workaround is to call asyncio.sleep with a short delay, but users likely won't find that solution on their own

List the steps.

Set up the client with a command and a listener for the on_command event. In the event, access ctx.command

What you expected.

ctx.command to be a Command instance

What you saw.

ctx.command is None

What version of the library did you use?

release

Version specification

4.3.2

Code of Conduct

  • I agree to follow the contribution requirements.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions