Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Parameter injections don't support autocomplete when nested #982

Open
3 tasks done
shiftinv opened this issue Mar 9, 2023 · 0 comments
Open
3 tasks done

Parameter injections don't support autocomplete when nested #982

shiftinv opened this issue Mar 9, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@shiftinv
Copy link
Member

shiftinv commented Mar 9, 2023

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)

@shiftinv shiftinv added unconfirmed bug Something might not be working bug Something isn't working and removed unconfirmed bug Something might not be working labels Mar 9, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant