File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -491,15 +491,24 @@ async def _invoke(self, ctx: ApplicationContext) -> None:
491
491
await self .callback (ctx , ** kwargs )
492
492
493
493
async def invoke_autocomplete_callback (self , interaction : Interaction ):
494
+ values = { i .name : i .default for i in self .options }
495
+
494
496
for op in interaction .data .get ("options" , []):
495
497
if op .get ("focused" , False ):
496
498
option = find (lambda o : o .name == op ["name" ], self .options )
497
- result = await option .autocomplete (interaction , op .get ("value" , None ))
499
+ values .update ({
500
+ i ["name" ]:i ["value" ]
501
+ for i in interaction .data ["options" ]
502
+ })
503
+ # This will only pass args depending on the argcount
504
+ arg_count = option .autocomplete .__code__ .co_argcount
505
+ args = [interaction , op .get ("value" , None ), values ][:arg_count ]
506
+ result = await option .autocomplete (* args )
498
507
choices = [
499
508
o if isinstance (o , OptionChoice ) else OptionChoice (o )
500
509
for o in result
501
510
]
502
- await interaction .response .send_autocomplete_result (choices = choices )
511
+ return await interaction .response .send_autocomplete_result (choices = choices )
503
512
504
513
def qualified_name (self ):
505
514
return self .name
You can’t perform that action at this time.
0 commit comments