4545 Union ,
4646)
4747
48+ from discord .interactions import AutocompleteInteraction , Interaction
49+
4850from ..channel import PartialMessageable , _threaded_guild_channel_factory
4951from ..channel .thread import Thread
5052from ..enums import Enum as DiscordEnum
111113
112114
113115def wrap_callback (coro ):
114- from ..ext .commands .errors import CommandError # noqa: PLC0415
116+ from ..ext .commands .errors import CommandError
115117
116118 @functools .wraps (coro )
117119 async def wrapped (* args , ** kwargs ):
@@ -131,7 +133,7 @@ async def wrapped(*args, **kwargs):
131133
132134
133135def hooked_wrapped_callback (command , ctx , coro ):
134- from ..ext .commands .errors import CommandError # noqa: PLC0415
136+ from ..ext .commands .errors import CommandError
135137
136138 @functools .wraps (coro )
137139 async def wrapped (arg ):
@@ -188,7 +190,7 @@ class ApplicationCommand(_BaseCommand, Generic[CogT, P, T]):
188190 cog = None
189191
190192 def __init__ (self , func : Callable , ** kwargs ) -> None :
191- from ..ext .commands .cooldowns import BucketType , CooldownMapping , MaxConcurrency # noqa: PLC0415
193+ from ..ext .commands .cooldowns import BucketType , CooldownMapping , MaxConcurrency
192194
193195 cooldown = getattr (func , "__commands_cooldown__" , kwargs .get ("cooldown" ))
194196
@@ -330,7 +332,7 @@ def _prepare_cooldowns(self, ctx: ApplicationContext):
330332 retry_after = bucket .update_rate_limit (current )
331333
332334 if retry_after :
333- from ..ext .commands .errors import CommandOnCooldown # noqa: PLC0415
335+ from ..ext .commands .errors import CommandOnCooldown
334336
335337 raise CommandOnCooldown (bucket , retry_after , self ._buckets .type ) # type: ignore
336338
@@ -1005,7 +1007,7 @@ async def _invoke(self, ctx: ApplicationContext) -> None:
10051007 arg = Object (id = int (arg ))
10061008
10071009 elif op .input_type == SlashCommandOptionType .string and (converter := op .converter ) is not None :
1008- from discord .ext .commands import Converter # noqa: PLC0415
1010+ from discord .ext .commands import Converter
10091011
10101012 if isinstance (converter , Converter ):
10111013 if isinstance (converter , type ):
@@ -1044,10 +1046,10 @@ async def _invoke(self, ctx: ApplicationContext) -> None:
10441046 else :
10451047 await self .callback (ctx , ** kwargs )
10461048
1047- async def invoke_autocomplete_callback (self , ctx : AutocompleteContext ) :
1049+ async def invoke_autocomplete_callback (self , interaction : AutocompleteInteraction ) -> None :
10481050 values = {i .name : i .default for i in self .options }
10491051
1050- for op in ctx . interaction .data .get ("options" , []):
1052+ for op in interaction .data .get ("options" , []):
10511053 if op .get ("focused" , False ):
10521054 # op_name is used because loop variables leak in surrounding scope
10531055 option = find (lambda o , op_name = op ["name" ]: o .name == op_name , self .options )
@@ -1057,12 +1059,6 @@ async def invoke_autocomplete_callback(self, ctx: AutocompleteContext):
10571059 ctx .value = op .get ("value" )
10581060 ctx .options = values
10591061
1060- if option .autocomplete ._is_instance_method :
1061- instance = getattr (option .autocomplete , "__self__" , ctx .cog )
1062- result = option .autocomplete (instance , ctx )
1063- else :
1064- result = option .autocomplete (ctx )
1065-
10661062 if inspect .isawaitable (result ):
10671063 result = await result
10681064
@@ -1232,7 +1228,7 @@ def __init__(
12321228 self .description_localizations : dict [str , str ] = kwargs .get ("description_localizations" , MISSING )
12331229
12341230 # similar to ApplicationCommand
1235- from ..ext .commands .cooldowns import BucketType , CooldownMapping , MaxConcurrency # noqa: PLC0415
1231+ from ..ext .commands .cooldowns import BucketType , CooldownMapping , MaxConcurrency
12361232
12371233 # no need to getattr, since slash cmds groups cant be created using a decorator
12381234
@@ -1418,11 +1414,10 @@ async def _invoke(self, ctx: ApplicationContext) -> None:
14181414 ctx .interaction .data = option
14191415 await command .invoke (ctx )
14201416
1421- async def invoke_autocomplete_callback (self , ctx : AutocompleteContext ) -> None :
1422- option = ctx . interaction .data ["options" ][0 ]
1417+ async def invoke_autocomplete_callback (self , interaction : AutocompleteInteraction ) -> None :
1418+ option = interaction .data ["options" ][0 ]
14231419 command = find (lambda x : x .name == option ["name" ], self .subcommands )
1424- ctx .interaction .data = option
1425- await command .invoke_autocomplete_callback (ctx )
1420+ await command .invoke_autocomplete_callback (interaction )
14261421
14271422 async def call_before_hooks (self , ctx : ApplicationContext ) -> None :
14281423 # only call local hooks
0 commit comments