Skip to content

[BUG] NoneType exception when using extension_autocomplete and disable_sync=True #582

@V3ntus

Description

@V3ntus

Describe the bug.

When attempting to register an autocomplete callback inside an extension with disable_sync=True, a NoneType exception occurs

List the steps.

Define a command with autocomplete option and an autocomplete callback in an extension:

@interactions.extension_command(
    name="testauto",
    description="test autocomplete",
    options=[
        Option(
            type=OptionType.STRING,
            name="message",
            description="test",
            autocomplete=True
        )
    ]
)
async def testauto_cmd(self, ctx: interactions.CommandContext, message: str = None):
    await ctx.send("You sent: {}".format(message))

@interactions.extension_autocomplete(command="test", name="message")
async def do_autocomplete(self, ctx):
    await ctx.populate([
        Choice(
            name="One",
            value="1"
        ),
        Choice(
            name="Two",
            value="2"
        )
    ])

What you expected.

To register a callback successfully

What you saw.

Traceback (most recent call last):
  File "/Users/ventus/GitRepos/discord-py-interactions_boilerplate/main.py", line 75, in <module>
    client.load("cogs." + cog)
  File "/Users/ventus/GitRepos/discord-py-interactions_boilerplate/env/lib/python3.9/site-packages/interactions/client.py", line 937, in load
    raise error from error
  File "/Users/ventus/GitRepos/discord-py-interactions_boilerplate/env/lib/python3.9/site-packages/interactions/client.py", line 933, in load
    extension = setup(self, *args, **kwargs)
  File "/Users/ventus/GitRepos/discord-py-interactions_boilerplate/cogs/helloworld.py", line 188, in setup
    HelloWorld(client)
  File "/Users/ventus/GitRepos/discord-py-interactions_boilerplate/env/lib/python3.9/site-packages/interactions/client.py", line 1143, in __new__
    func = client.autocomplete(*args, **kwargs)(func)
  File "/Users/ventus/GitRepos/discord-py-interactions_boilerplate/env/lib/python3.9/site-packages/interactions/client.py", line 850, in autocomplete
    _command: Union[Snowflake, int] = int(_command_obj.id)
AttributeError: 'NoneType' object has no attribute 'id'

What version of the library did you use?

stable

Code of Conduct

  • I agree to follow the contribution requirements.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

Status

Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions