[commands] Add Context.invoked_parents

This commit is contained in:
Sebastian Law
2021-02-22 05:17:13 -08:00
committed by Danny
parent 427e387a2f
commit 1afc127458
2 changed files with 15 additions and 0 deletions

View File

@ -1342,6 +1342,8 @@ class Group(GroupMixin, Command):
injected = hooked_wrapped_callback(self, ctx, self.callback)
await injected(*ctx.args, **ctx.kwargs)
ctx.invoked_parents.append(ctx.invoked_with)
if trigger and ctx.invoked_subcommand:
ctx.invoked_with = trigger
await ctx.invoked_subcommand.invoke(ctx)
@ -1380,6 +1382,8 @@ class Group(GroupMixin, Command):
if call_hooks:
await self.call_after_hooks(ctx)
ctx.invoked_parents.append(ctx.invoked_with)
if trigger and ctx.invoked_subcommand:
ctx.invoked_with = trigger
await ctx.invoked_subcommand.reinvoke(ctx, call_hooks=call_hooks)