mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-12 00:39:56 +00:00
[commands] Context.invoke just invokes a command with no special case.
Previously it would both forward and invoke depending if there were no kwargs given. Now it just passes in the arguments to another command without doing any special casing on the no argument case.
This commit is contained in:
parent
a636f6ae6f
commit
1688d513e8
@ -81,8 +81,36 @@ class Context:
|
||||
self.subcommand_passed = attrs.pop('subcommand_passed', None)
|
||||
|
||||
@asyncio.coroutine
|
||||
def invoke(self, command, **kwargs):
|
||||
if len(kwargs) == 0:
|
||||
yield from command.invoke(self)
|
||||
else:
|
||||
yield from command.callback(**kwargs)
|
||||
def invoke(self, command, *args, **kwargs):
|
||||
"""|coro|
|
||||
|
||||
Calls a command with the arguments given.
|
||||
|
||||
This is useful if you want to just call the callback that a
|
||||
:class:`Command` holds internally.
|
||||
|
||||
Note
|
||||
------
|
||||
You do not pass in the context as it is done for you.
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
command : :class:`Command`
|
||||
A command or superclass of a command that is going to be called.
|
||||
\*args
|
||||
The arguments to to use.
|
||||
\*\*kwargs
|
||||
The keyword arguments to use.
|
||||
"""
|
||||
|
||||
arguments = []
|
||||
if command.instance is not None:
|
||||
arguments.append(command.instance)
|
||||
|
||||
if command.pass_context:
|
||||
arguments.append(self)
|
||||
|
||||
arguments.extend(args)
|
||||
|
||||
yield from command.callback(*arguments, **kwargs)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user