Skip to content

Commit 7380956

Browse files
authored
clean up autocomplete example (#281)
1 parent 1742844 commit 7380956

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

docs/interactions/application-commands/slash-commands.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,12 @@ bot.run("TOKEN")
214214
</Tabs>
215215

216216
## Autocomplete
217-
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.
217+
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:
218218

219219
```py
220220
async def get_animal_types(ctx: discord.AutocompleteContext):
221221
"""
222-
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
222+
Here we will check if 'ctx.options['animal_type']' is a marine or land animal and return respective option choices
223223
"""
224224
animal_type = ctx.options['animal_type']
225225
if animal_type == 'Marine':
@@ -228,7 +228,11 @@ async def get_animal_types(ctx: discord.AutocompleteContext):
228228
return ['Snake', 'Wolf', 'Lizard', 'Lion', 'Bird']
229229

230230
@bot.slash_command(name="animal")
231-
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)):
231+
async def animal_command(
232+
ctx: discord.ApplicationContext,
233+
animal_type: discord.Option(str, choices=['Marine', 'Land']),
234+
animal: discord.Option(str, autocomplete=discord.utils.basic_autocomplete(get_animal_types))
235+
):
232236
await ctx.respond(f'You picked an animal type of `{animal_type}` that led you to pick `{animal}`!')
233237
```
234238

0 commit comments

Comments
 (0)