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

Add utils.basic_autocomplete #348

Merged
merged 6 commits into from
Nov 1, 2021

Conversation

BobDotCom
Copy link
Member

@BobDotCom BobDotCom commented Oct 29, 2021

Summary

Adds a basic autocomplete function to utils. Usage:

import discord
from discord import option
from discord.utils import basic_autocomplete

bot = discord.Bot()

@bot.slash_command()
@option("color", autocomplete=basic_autocomplete(["red", "orange", "yellow", "green", "blue", "purple", "red-orange"]))
async def test_color(ctx, color):
    await ctx.respond(f"Your choice: {color}")
    
async def autocomplete(interaction):
    return [str(num) for num in range(1, len(interaction.user.display_name))]

@bot.slash_command()
@option("number", autocomplete=basic_autocomplete(autocomplete))
async def test_number(ctx, number):
    await ctx.respond(f"Your choice: {number}")

Screen Shot 2021-10-29 at 11 53 47 AM
Screen Shot 2021-10-29 at 11 54 01 AM
Screen Shot 2021-10-29 at 11 54 15 AM

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, ...)

@BobDotCom BobDotCom marked this pull request as draft October 29, 2021 16:01
auto-merge was automatically disabled October 29, 2021 16:01

Pull request was converted to draft

@BobDotCom BobDotCom marked this pull request as ready for review October 29, 2021 16:56
discord/utils.py Outdated Show resolved Hide resolved
discord/utils.py Outdated Show resolved Hide resolved
@Lulalaby Lulalaby added feature Implements a feature priority: medium Medium Priority status: in progress Work in Progess labels Oct 30, 2021
discord/utils.py Outdated Show resolved Hide resolved
Co-authored-by: Izhar Ahmad <54180221+nerdguyahmad@users.noreply.github.com>
@Lulalaby Lulalaby added this to In progress in v2.0 via automation Nov 1, 2021
Copy link
Member

@Lulalaby Lulalaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BobDotCom BobDotCom merged commit 5552509 into Pycord-Development:master Nov 1, 2021
v2.0 automation moved this from In progress to Done Nov 1, 2021
@BobDotCom BobDotCom deleted the utils-autocomplete branch November 1, 2021 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Implements a feature priority: medium Medium Priority status: in progress Work in Progess
Projects
No open projects
v2.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants