diff options
| author | Rapptz <[email protected]> | 2021-04-04 06:21:30 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-04-04 07:04:01 -0400 |
| commit | adaf7c619200a33925c71851e04b7f50f043bc54 (patch) | |
| tree | cdf661c7a94e2d39ef3b56f20a329ddfbab31e0a /discord/ext/commands/context.py | |
| parent | Modernize code to use f-strings (diff) | |
| download | discord.py-adaf7c619200a33925c71851e04b7f50f043bc54.tar.xz discord.py-adaf7c619200a33925c71851e04b7f50f043bc54.zip | |
[commands] Use positional only parameter for Context.invoke
Diffstat (limited to 'discord/ext/commands/context.py')
| -rw-r--r-- | discord/ext/commands/context.py | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/discord/ext/commands/context.py b/discord/ext/commands/context.py index e0eb7a5c..5e83b1ab 100644 --- a/discord/ext/commands/context.py +++ b/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 |