mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-20 16:00:29 +00:00
[commands] Fix bug where subgroups would be repeatedly called.
This happened due to not resetting the `invoked_subcommand` state tracking. Since the `invoked_subcommand` was not reset, it would always assume that it was valid and repeatedly call it when passed invalid subcommands/arguments.
This commit is contained in:
parent
24a9da04db
commit
9d9a20c128
@ -367,6 +367,11 @@ class Command:
|
||||
def invoke(self, ctx):
|
||||
self._verify_checks(ctx)
|
||||
yield from self._parse_arguments(ctx)
|
||||
|
||||
# terminate the invoked_subcommand chain.
|
||||
# since we're in a regular command (and not a group) then
|
||||
# the invoked subcommand is None.
|
||||
ctx.invoked_subcommand = None
|
||||
injected = inject_context(ctx, self.callback)
|
||||
yield from injected(*ctx.args, **ctx.kwargs)
|
||||
|
||||
@ -593,8 +598,7 @@ class Group(GroupMixin, Command):
|
||||
|
||||
if trigger:
|
||||
ctx.subcommand_passed = trigger
|
||||
if trigger in self.commands:
|
||||
ctx.invoked_subcommand = self.commands[trigger]
|
||||
ctx.invoked_subcommand = self.commands.get(trigger, None)
|
||||
|
||||
if early_invoke:
|
||||
injected = inject_context(ctx, self.callback)
|
||||
|
Loading…
x
Reference in New Issue
Block a user