Browse Source

[commands] Use positional only parameter for Context.invoke

pull/6620/head
Rapptz 4 years ago
parent
commit
adaf7c6192
  1. 14
      discord/ext/commands/context.py

14
discord/ext/commands/context.py

@ -91,7 +91,7 @@ class Context(discord.abc.Messageable):
self.command_failed = attrs.pop('command_failed', False)
self._state = self.message._state
async def invoke(self, *args, **kwargs):
async def invoke(self, command, /, *args, **kwargs):
r"""|coro|
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
using this function.
.. warning::
The first parameter passed **must** be the command being invoked.
Parameters
-----------
command: :class:`.Command`
@ -126,18 +122,12 @@ class Context(discord.abc.Messageable):
TypeError
The command argument to invoke is missing.
"""
try:
command = args[0]
except IndexError:
raise TypeError('Missing command to invoke.') from None
arguments = []
if command.cog is not None:
arguments.append(command.cog)
arguments.append(self)
arguments.extend(args[1:])
arguments.extend(args)
ret = await command.callback(*arguments, **kwargs)
return ret

Loading…
Cancel
Save