aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-04-19 04:41:32 -0400
committerRapptz <[email protected]>2021-04-19 04:41:32 -0400
commit09f3f2111ce52f00d1c682e5cc05dee49a9a3913 (patch)
tree6271b2e03e1d8b7a1ad750b426ba1727ae437b46
parentAdd a third overload to parse_time (diff)
downloaddiscord.py-09f3f2111ce52f00d1c682e5cc05dee49a9a3913.tar.xz
discord.py-09f3f2111ce52f00d1c682e5cc05dee49a9a3913.zip
[commands] Add Context.current_parameter
-rw-r--r--discord/ext/commands/context.py6
-rw-r--r--discord/ext/commands/core.py1
2 files changed, 7 insertions, 0 deletions
diff --git a/discord/ext/commands/context.py b/discord/ext/commands/context.py
index e9c3a168..9699261d 100644
--- a/discord/ext/commands/context.py
+++ b/discord/ext/commands/context.py
@@ -53,6 +53,11 @@ class Context(discord.abc.Messageable):
A dictionary of transformed arguments that were passed into the command.
Similar to :attr:`args`\, if this is accessed in the
:func:`on_command_error` event then this dict could be incomplete.
+ current_parameter: Optional[:class:`inspect.Parameter`]
+ The parameter that is currently being inspected and converted.
+ This is only of use for within converters.
+
+ .. versionadded:: 2.0
prefix: :class:`str`
The prefix that was used to invoke the command.
command: :class:`Command`
@@ -94,6 +99,7 @@ class Context(discord.abc.Messageable):
self.invoked_subcommand = attrs.pop('invoked_subcommand', None)
self.subcommand_passed = attrs.pop('subcommand_passed', None)
self.command_failed = attrs.pop('command_failed', False)
+ self.current_parameter = attrs.pop('current_parameter', None)
self._state = self.message._state
async def invoke(self, command, /, *args, **kwargs):
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
index 22f1b234..cbdd4fcf 100644
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -819,6 +819,7 @@ class Command(_BaseCommand):
raise discord.ClientException(f'Callback for {self.name} command is missing "ctx" parameter.')
for name, param in iterator:
+ ctx.current_parameter = param
if param.kind in (param.POSITIONAL_OR_KEYWORD, param.POSITIONAL_ONLY):
transformed = await self.transform(ctx, param)
args.append(transformed)