Skip to content

Commit 5263a4d

Browse files
author
Chicc
authored
Merge pull request #670 from Pycord-Development/revert-647-reload-app-commands
Revert "Ability to reload application command callbacks"
2 parents 51d110b + 116e666 commit 5263a4d

File tree

1 file changed

+18
-32
lines changed

1 file changed

+18
-32
lines changed

discord/bot.py

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,7 @@ def add_application_command(self, command: ApplicationCommand) -> None:
124124

125125
if self.debug_guilds and command.guild_ids is None:
126126
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)
135128

136129
def remove_application_command(
137130
self, command: ApplicationCommand
@@ -490,32 +483,25 @@ async def process_application_commands(self, interaction: Interaction) -> None:
490483
try:
491484
command = self._application_commands[interaction.data["id"]]
492485
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)
504494
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)
513503
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)
519505

520506
def slash_command(self, **kwargs):
521507
"""A shortcut decorator that invokes :func:`.ApplicationCommandMixin.command` and adds it to

0 commit comments

Comments
 (0)