Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implement autocomplete #346

Merged
merged 3 commits into from
Oct 29, 2021
Merged

Implement autocomplete #346

merged 3 commits into from
Oct 29, 2021

Conversation

CodeWithSwastik
Copy link
Contributor

@CodeWithSwastik CodeWithSwastik commented Oct 29, 2021

Summary

This PR implements autocomplete. #277 was outdated so I moved it to this.
Closes #255

Example

COLORS = ["red", "blue", "black", "brown", "yellow"]

async def color_picker(interaction, value):
    return [x for x in COLORS if x.startswith(value.lower())]

@bot.slash_command()
@option("color", autocomplete=color_picker)
async def test(ctx, color):
    await ctx.respond(f"Your choice: {color}")

image

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, typehinting, ...)

@CodeWithSwastik CodeWithSwastik mentioned this pull request Oct 29, 2021
6 tasks
CodeWithSwastik and others added 2 commits October 29, 2021 20:03
Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com>
Co-authored-by: Izhar Ahmad <54180221+nerdguyahmad@users.noreply.github.com>
@BobDotCom BobDotCom merged commit 1e77d6e into master Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-completion support for slash command option choices.
5 participants