[commands] Add Context.current_argument

This commit is contained in:
jack1142
2022-04-01 22:24:14 +02:00
committed by GitHub
parent 5c14149873
commit 3d914e08e0
2 changed files with 12 additions and 5 deletions

View File

@ -96,6 +96,11 @@ class Context(discord.abc.Messageable, Generic[BotT]):
The parameter that is currently being inspected and converted.
This is only of use for within converters.
.. versionadded:: 2.0
current_argument: Optional[:class:`str`]
The argument string of the :attr:`current_parameter` that is currently being converted.
This is only of use for within converters.
.. versionadded:: 2.0
prefix: Optional[:class:`str`]
The prefix that was used to invoke the command.
@ -141,6 +146,7 @@ class Context(discord.abc.Messageable, Generic[BotT]):
subcommand_passed: Optional[str] = None,
command_failed: bool = False,
current_parameter: Optional[inspect.Parameter] = None,
current_argument: Optional[str] = None,
):
self.message: Message = message
self.bot: BotT = bot
@ -155,6 +161,7 @@ class Context(discord.abc.Messageable, Generic[BotT]):
self.subcommand_passed: Optional[str] = subcommand_passed
self.command_failed: bool = command_failed
self.current_parameter: Optional[inspect.Parameter] = current_parameter
self.current_argument: Optional[str] = current_argument
self._state: ConnectionState = self.message._state
async def invoke(self, command: Command[CogT, P, T], /, *args: P.args, **kwargs: P.kwargs) -> T: