diff --git a/docs/interactions/application-commands/slash-commands.mdx b/docs/interactions/application-commands/slash-commands.mdx index 0d02dcf2..ad144509 100644 --- a/docs/interactions/application-commands/slash-commands.mdx +++ b/docs/interactions/application-commands/slash-commands.mdx @@ -214,12 +214,12 @@ bot.run("TOKEN") ## Autocomplete -Discord's autocomplete allows developers to determine option choices that are used in a slash command option. By defining a function, you can do this. +Discord's autocomplete allows developers to determine option choices that are used in a slash command option. You can do this by defining a function: ```py async def get_animal_types(ctx: discord.AutocompleteContext): """ - Here we will check if 'ctx.options['animal_type']' is and check if it's a marine or land animal and return specific option choices + Here we will check if 'ctx.options['animal_type']' is a marine or land animal and return respective option choices """ animal_type = ctx.options['animal_type'] if animal_type == 'Marine': @@ -228,7 +228,11 @@ async def get_animal_types(ctx: discord.AutocompleteContext): return ['Snake', 'Wolf', 'Lizard', 'Lion', 'Bird'] @bot.slash_command(name="animal") -async def animal_command(ctx: discord.ApplicationContext, animal_type: discord.Option(str, choices=['Marine', 'Land']), animal: discord.Option(str, autocomplete=discord.utils.basic_autocomplete(get_animals)): +async def animal_command( + ctx: discord.ApplicationContext, + animal_type: discord.Option(str, choices=['Marine', 'Land']), + animal: discord.Option(str, autocomplete=discord.utils.basic_autocomplete(get_animal_types)) +): await ctx.respond(f'You picked an animal type of `{animal_type}` that led you to pick `{animal}`!') ``` diff --git a/yarn.lock b/yarn.lock index b58ebc87..00f84dfe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8904,9 +8904,9 @@ typescript@4.9.4: integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg== ua-parser-js@^0.7.30: - version "0.7.31" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6" - integrity sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ== + version "0.7.33" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.33.tgz#1d04acb4ccef9293df6f70f2c3d22f3030d8b532" + integrity sha512-s8ax/CeZdK9R/56Sui0WM6y9OFREJarMRHqLB2EwkovemBxNQ+Bqu8GAsUnVcXKgphb++ghr/B2BZx4mahujPw== unherit@^1.0.4: version "1.1.3"