From 9d9a20c12821ac845b01c2535937347b53549215 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 4 Jun 2016 22:04:05 -0400 Subject: [PATCH] [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. --- discord/ext/commands/core.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index b5509530e..e5c67c70c 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -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)