Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ These changes are available on the `master` branch, but have not yet been releas
([#3320](https://github.com/Pycord-Development/pycord/pull/3320))
- Fix `SyntaxWarning` about `return` in a `finally` block raised on Python 3.14+
([#3332](https://github.com/Pycord-Development/pycord/pull/3334))
- Fix `ctx.command.qualified_name` returning only the parent `SlashCommandGroup` name
instead of the full subcommand path when accessed inside `cog_check`.
([#3363](https://github.com/Pycord-Development/pycord/pull/3363))

### Deprecated

Expand Down
26 changes: 26 additions & 0 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,32 @@ def inner(cls: type[SlashCommandGroup]) -> SlashCommandGroup:

return inner

async def prepare(self, ctx: ApplicationContext) -> None:
# Resolve down to the actual leaf subcommand
leaf, data = self, ctx.interaction.data
while isinstance(leaf, SlashCommandGroup):
data = data["options"][0]
leaf = find(lambda x: x.name == data["name"], leaf.subcommands)

ctx.command = leaf

if not await self.can_run(ctx):
raise CheckFailure(
f"The check functions for the command {self.name} failed"
)

if self._max_concurrency is not None:
# For this application, context can be duck-typed as a Message
await self._max_concurrency.acquire(ctx) # type: ignore # ctx instead of non-existent message

try:
self._prepare_cooldowns(ctx)
await self.call_before_hooks(ctx)
except:
if self._max_concurrency is not None:
await self._max_concurrency.release(ctx) # type: ignore # ctx instead of non-existent message
raise

async def _invoke(self, ctx: ApplicationContext) -> None:
option = ctx.interaction.data["options"][0]
resolved = ctx.interaction.data.get("resolved", None)
Expand Down