Skip to content

Parameter injections don't support autocomplete when nested #982

Open
@shiftinv

Description

@shiftinv

Summary

See title

Reproduction Steps

Create a command, add an injection parameter (arg) which itself has another injection parameter (d).
Autocomplete for options of the nested injection parameter doesn't work.

Minimal Reproducible Code

@commands.injection()
def inj1(a: str, b: str):
    return a + b

@inj1.autocomplete("a")  # doesn't work
def autocomp_a(inter, value):
    return [value]

@commands.injection()
def inj2(c: str, d = inj1):
    return c + d

@inj2.autocomplete("c")  # works
def autocomp_c(inter, value):
    return [value]

@bot.slash_command()
async def cmd(inter, arg = inj2):
    await inter.send(arg)

Expected Results

Both a and c have autocomplete enabled.

Actual Results

Only c autocompletes, the a option is registered with "autocomplete": false.

Intents

n/a

System Information

fe2690b5b16b0dcf0aa4676d0213b75250d275dd

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

#670

def collect_nested_params(function: Callable) -> List[ParamInfo]:
"""Collect all options from a function"""
# TODO: Have these be actually sorted properly and not have injections always at the end
_, _, paraminfos, injections = collect_params(function)
for injection in injections.values():
paraminfos += collect_nested_params(injection.function)
return sorted(paraminfos, key=lambda param: not param.required)

Metadata

Metadata

Assignees

No one assigned

    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