Skip to content

Commit 8b6415b

Browse files
authored
docs: make autocomplete usage clearer (#1462)
1 parent 21f51b4 commit 8b6415b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

docs/src/Guides/03 Creating Commands.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,20 +262,23 @@ from interactions import AutocompleteContext
262262

263263
@my_command.autocomplete("string_option")
264264
async def autocomplete(self, ctx: AutocompleteContext):
265-
# make sure this is done within three seconds
265+
string_option_input = ctx.input_text # can be empty
266+
# you can use ctx.kwargs.get("name") for other options - note they can be empty too
267+
268+
# make sure you respond within three seconds
266269
await ctx.send(
267270
choices=[
268271
{
269-
"name": f"{ctx.input_text}a",
270-
"value": f"{ctx.input_text}a",
272+
"name": f"{string_option_input}a",
273+
"value": f"{string_option_input}a",
271274
},
272275
{
273-
"name": f"{ctx.input_text}b",
274-
"value": f"{ctx.input_text}b",
276+
"name": f"{string_option_input}b",
277+
"value": f"{string_option_input}b",
275278
},
276279
{
277-
"name": f"{ctx.input_text}c",
278-
"value": f"{ctx.input_text}c",
280+
"name": f"{string_option_input}c",
281+
"value": f"{string_option_input}c",
279282
},
280283
]
281284
)

0 commit comments

Comments
 (0)