Skip to content

Commit

Permalink
Allow get_command to find subcommands without having to call cmd.get_…
Browse files Browse the repository at this point in the history
…subcommand explicitly
  • Loading branch information
tandemdude committed Dec 21, 2020
1 parent 518eddc commit 5f422fd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lightbulb/command_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,18 @@ def get_command(self, name: str) -> typing.Optional[commands.Command]:
Returns:
Optional[ :obj:`~.commands.Command` ]: Command object registered to that name.
"""
return self._commands.get(name)
tokens = name.split()
this = self._commands.get(tokens.pop(0))

if not tokens:
return this
if this is None:
return this

for token in tokens:
this = this.get_subcommand(token)

return this

def get_plugin(self, name: str) -> typing.Optional[plugins.Plugin]:
"""
Expand Down

0 comments on commit 5f422fd

Please sign in to comment.