[commands] Use positional only parameter for Context.invoke
This commit is contained in:
parent
9d39b135f4
commit
adaf7c6192
@ -91,7 +91,7 @@ class Context(discord.abc.Messageable):
|
|||||||
self.command_failed = attrs.pop('command_failed', False)
|
self.command_failed = attrs.pop('command_failed', False)
|
||||||
self._state = self.message._state
|
self._state = self.message._state
|
||||||
|
|
||||||
async def invoke(self, *args, **kwargs):
|
async def invoke(self, command, /, *args, **kwargs):
|
||||||
r"""|coro|
|
r"""|coro|
|
||||||
|
|
||||||
Calls a command with the arguments given.
|
Calls a command with the arguments given.
|
||||||
@ -108,10 +108,6 @@ class Context(discord.abc.Messageable):
|
|||||||
You must take care in passing the proper arguments when
|
You must take care in passing the proper arguments when
|
||||||
using this function.
|
using this function.
|
||||||
|
|
||||||
.. warning::
|
|
||||||
|
|
||||||
The first parameter passed **must** be the command being invoked.
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
-----------
|
-----------
|
||||||
command: :class:`.Command`
|
command: :class:`.Command`
|
||||||
@ -126,18 +122,12 @@ class Context(discord.abc.Messageable):
|
|||||||
TypeError
|
TypeError
|
||||||
The command argument to invoke is missing.
|
The command argument to invoke is missing.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
|
||||||
command = args[0]
|
|
||||||
except IndexError:
|
|
||||||
raise TypeError('Missing command to invoke.') from None
|
|
||||||
|
|
||||||
arguments = []
|
arguments = []
|
||||||
if command.cog is not None:
|
if command.cog is not None:
|
||||||
arguments.append(command.cog)
|
arguments.append(command.cog)
|
||||||
|
|
||||||
arguments.append(self)
|
arguments.append(self)
|
||||||
arguments.extend(args[1:])
|
arguments.extend(args)
|
||||||
|
|
||||||
ret = await command.callback(*arguments, **kwargs)
|
ret = await command.callback(*arguments, **kwargs)
|
||||||
return ret
|
return ret
|
||||||
|
Loading…
x
Reference in New Issue
Block a user