@@ -124,14 +124,7 @@ def add_application_command(self, command: ApplicationCommand) -> None:
124
124
125
125
if self .debug_guilds and command .guild_ids is None :
126
126
command .guild_ids = self .debug_guilds
127
-
128
- for cmd in self .pending_application_commands :
129
- if cmd == command :
130
- command .id = cmd .id
131
- self ._application_commands [command .id ] = command
132
- break
133
- else :
134
- self ._pending_application_commands .append (command )
127
+ self ._pending_application_commands .append (command )
135
128
136
129
def remove_application_command (
137
130
self , command : ApplicationCommand
@@ -490,32 +483,25 @@ async def process_application_commands(self, interaction: Interaction) -> None:
490
483
try :
491
484
command = self ._application_commands [interaction .data ["id" ]]
492
485
except KeyError :
493
- for cmd in self .application_commands :
494
- if (
495
- cmd .name == interaction .data ["name" ]
496
- and interaction .data ["guild_id" ] in cmd .guild_ids
497
- ):
498
- command = cmd
499
- break
500
- else :
501
- return self .dispatch ("unknown_command" , interaction )
502
- if interaction .type is InteractionType .auto_complete :
503
- ctx = await self .get_autocomplete_context (interaction )
486
+ self .dispatch ("unknown_command" , interaction )
487
+ else :
488
+ if interaction .type is InteractionType .auto_complete :
489
+ ctx = await self .get_autocomplete_context (interaction )
490
+ ctx .command = command
491
+ return await command .invoke_autocomplete_callback (ctx )
492
+
493
+ ctx = await self .get_application_context (interaction )
504
494
ctx .command = command
505
- return await command . invoke_autocomplete_callback ( ctx )
506
-
507
- ctx = await self .get_application_context ( interaction )
508
- ctx .command = command
509
- self . dispatch ( "application_command" , ctx )
510
- try :
511
- if await self . can_run ( ctx , call_once = True ) :
512
- await ctx .command .invoke (ctx )
495
+ self . dispatch ( "application_command" , ctx )
496
+ try :
497
+ if await self .can_run ( ctx , call_once = True ):
498
+ await ctx .command . invoke ( ctx )
499
+ else :
500
+ raise CheckFailure ( "The global check once functions failed." )
501
+ except DiscordException as exc :
502
+ await ctx .command .dispatch_error (ctx , exc )
513
503
else :
514
- raise CheckFailure ("The global check once functions failed." )
515
- except DiscordException as exc :
516
- await ctx .command .dispatch_error (ctx , exc )
517
- else :
518
- self .dispatch ("application_command_completion" , ctx )
504
+ self .dispatch ("application_command_completion" , ctx )
519
505
520
506
def slash_command (self , ** kwargs ):
521
507
"""A shortcut decorator that invokes :func:`.ApplicationCommandMixin.command` and adds it to
0 commit comments