mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-09 23:39:50 +00:00
[commands] Do not take up 'command' keyword-argument in Context.invoke.
It was annoying when commands would have a keyword-only argument named 'command', such as a help command or a disable command.
This commit is contained in:
parent
ad20e3066e
commit
ce34713c45
@ -87,7 +87,7 @@ class Context(discord.abc.Messageable):
|
|||||||
self._state = self.message._state
|
self._state = self.message._state
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def invoke(self, command, *args, **kwargs):
|
def invoke(self, *args, **kwargs):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
Calls a command with the arguments given.
|
Calls a command with the arguments given.
|
||||||
@ -99,9 +99,13 @@ class Context(discord.abc.Messageable):
|
|||||||
------
|
------
|
||||||
You do not pass in the context as it is done for you.
|
You do not pass in the context as it is done for you.
|
||||||
|
|
||||||
|
Warning
|
||||||
|
---------
|
||||||
|
The first parameter passed **must** be the command being invoked.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
-----------
|
-----------
|
||||||
command : :class:`.Command`
|
command: :class:`.Command`
|
||||||
A command or superclass of a command that is going to be called.
|
A command or superclass of a command that is going to be called.
|
||||||
\*args
|
\*args
|
||||||
The arguments to to use.
|
The arguments to to use.
|
||||||
@ -109,6 +113,11 @@ class Context(discord.abc.Messageable):
|
|||||||
The keyword arguments to use.
|
The keyword arguments to use.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
command = args[0]
|
||||||
|
except IndexError:
|
||||||
|
raise TypeError('Missing command to invoke.') from None
|
||||||
|
|
||||||
arguments = []
|
arguments = []
|
||||||
if command.instance is not None:
|
if command.instance is not None:
|
||||||
arguments.append(command.instance)
|
arguments.append(command.instance)
|
||||||
@ -116,7 +125,7 @@ class Context(discord.abc.Messageable):
|
|||||||
if command.pass_context:
|
if command.pass_context:
|
||||||
arguments.append(self)
|
arguments.append(self)
|
||||||
|
|
||||||
arguments.extend(args)
|
arguments.extend(args[1:])
|
||||||
|
|
||||||
ret = yield from command.callback(*arguments, **kwargs)
|
ret = yield from command.callback(*arguments, **kwargs)
|
||||||
return ret
|
return ret
|
||||||
|
Loading…
x
Reference in New Issue
Block a user