aboutsummaryrefslogtreecommitdiff
path: root/discord/ext
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-06-04 22:04:05 -0400
committerRapptz <[email protected]>2016-06-04 22:04:05 -0400
commit9d9a20c12821ac845b01c2535937347b53549215 (patch)
tree38e304a82964a505fabc88797b9cf8a29a3cdee8 /discord/ext
parent[commands] Cleanup Command.invoke code due to exception propagation. (diff)
downloaddiscord.py-9d9a20c12821ac845b01c2535937347b53549215.tar.xz
discord.py-9d9a20c12821ac845b01c2535937347b53549215.zip
[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.
Diffstat (limited to 'discord/ext')
-rw-r--r--discord/ext/commands/core.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
index b5509530..e5c67c70 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)