File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ async def constraint(
154154async def autocomplete_langs (
155155 inter : disnake .ApplicationCommandInteraction , string : str
156156) -> List [str ]:
157- return list ( filter ( lambda lang : string in lang .lower (), LANGUAGES ))
157+ return [ lang for lang in LANGUAGES if string in lang .lower ()]
158158
159159
160160@bot .slash_command ()
@@ -165,6 +165,21 @@ async def autocomplete(
165165 ...
166166
167167
168+ # From version 2.2.0
169+ # it's possible to create autocomplete options with the decorator @slash_command.autocomplete()
170+
171+
172+ @bot .slash_command ()
173+ async def languages (inter : disnake .ApplicationCommandInteraction , language : str ):
174+ ...
175+
176+
177+ @languages .autocomplete ("language" )
178+ async def language_autocomp (inter : disnake .ApplicationCommandInteraction , string : str ):
179+ string = string .lower ()
180+ return [lang for lang in LANGUAGES if string in lang .lower ()]
181+
182+
168183# You can use docstrings to set the description of the command or even
169184# the description of options. You should follow the ReStructuredText or numpy format.
170185@bot .slash_command ()
You can’t perform that action at this time.
0 commit comments