@@ -124,7 +124,14 @@ 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
- self ._pending_application_commands .append (command )
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 )
128
135
129
136
def remove_application_command (
130
137
self , command : ApplicationCommand
@@ -483,25 +490,32 @@ async def process_application_commands(self, interaction: Interaction) -> None:
483
490
try :
484
491
command = self ._application_commands [interaction .data ["id" ]]
485
492
except KeyError :
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 )
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 )
494
504
ctx .command = command
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 )
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 )
503
513
else :
504
- self .dispatch ("application_command_completion" , ctx )
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 )
505
519
506
520
def slash_command (self , ** kwargs ):
507
521
"""A shortcut decorator that invokes :func:`.ApplicationCommandMixin.command` and adds it to
0 commit comments