From adaf7c619200a33925c71851e04b7f50f043bc54 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 4 Apr 2021 06:21:30 -0400 Subject: [PATCH] [commands] Use positional only parameter for Context.invoke --- discord/ext/commands/context.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/discord/ext/commands/context.py b/discord/ext/commands/context.py index e0eb7a5ca..5e83b1ab2 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