Commit Graph
236 Commits
Author SHA1 Message Date
Rapptz 15bfdf66b2 [commands] Default construct flags if they're not passed as parameters
This only applies if and only if the flag can be default constructible.
Ergo, all the flags are optional or not required.
2021-04-20 08:00:47 -04:00
Rapptz c54e43360b [commands] Add run_converters helper to call converters 2021-04-19 04:46:02 -04:00
Rapptz 09f3f2111c [commands] Add Context.current_parameter 2021-04-19 04:41:32 -04:00
Rapptz 7fb746e6e5 [commands] Refactor evaluation functions to allow passing in localns 2021-04-18 04:10:19 -04:00
Rapptz 74b07a3218 [commands] Fix Command.clean_params to return a regular dict 2021-04-11 16:30:28 -04:00
Rapptz 74d8ad2013 [commands] Add support for Python 3.10 Union typing 2021-04-11 02:11:24 -04:00
Josh 7f91ae8b67 [commands] use __args__ and __origin__ where applicable 2021-04-11 00:38:17 -04:00
Rapptz 3151672cfe [commands] Refactor typing evaluation to not use get_type_hints
get_type_hints had a few issues:

1. It would convert = None default parameters to Optional
2. It would not allow values as type annotations
3. It would not implicitly convert some string literals as ForwardRef

In Python 3.9 `list['Foo']` does not convert into
`list[ForwardRef('Foo')]` even though `typing.List` does this
behaviour. In order to streamline it, evaluation had to be rewritten
manually to support our usecases.

This patch also flattens nested typing.Literal which was not done
until Python 3.9.2.
2021-04-10 20:56:08 -04:00
James bcd3a00eaf [commands] Make commands.Greedy a typing.Generic 2021-04-10 07:27:32 -04:00
Dan Hess f2d5ab6f80 [commands] Provide a dynamic cooldown system 2021-04-10 03:30:01 -04:00
Sigmath Bits 68aef92b37 [commands]Add typing.Literal converter 2021-04-10 02:50:59 -04:00
Rapptz 99fc950510 Use f-strings in more places that were missed. 2021-04-08 06:02:47 -04:00
Rapptz f80b8d3f5d [commands] Only replace annotation if one was given 2021-04-07 03:17:36 -04:00
Nadir Chowdhury 7a34de1570 [commands] Use typing.get_type_hints to resolve ForwardRefs 2021-04-06 23:24:23 -04:00
Rapptz 9ab58d302d [commands] Fix classmethod converters not working.
Protocols sure are annoying.
2021-04-05 23:52:28 -04:00
Rapptz ee5bb07c02 [commands] Revert conversion code back to how it was originally 2021-04-05 23:24:47 -04:00
ToxicKidz 0efb720cec [commands] Fix AttributeError for classes missing convert attribute 2021-04-05 23:12:27 -04:00
Michael H fbe6e2f520 [commands] Fix @classmethod converters 2021-04-05 20:25:23 -04:00
James 34ab772653 Use typing.Protocol instead of abc.ABCMeta 2021-04-04 18:05:49 -04:00
Rapptz 9d39b135f4 Modernize code to use f-strings
This also removes the encoding on the top, since Python 3 does it by
default. It also changes some methods to use `yield from`.
2021-04-04 07:03:53 -04:00
Mikey d61486278f [commands] allow arbitrary callables in cooldown 2021-03-28 06:31:51 -04:00
Sebastian Law a131e11c5e [commands] fix documented type for Command.checks 2021-03-24 08:24:14 -04:00
Nadir Chowdhury 63ec23bac2 Code optimisations and refactoring via Sourcery 2021-02-24 21:26:51 -05:00
Sebastian Law 1afc127458 [commands] Add Context.invoked_parents 2021-02-23 03:39:08 -05:00
Bryan Forbes 16e0adb315 [commands] Handle positional-only parameters in bot commands 2021-02-17 23:48:09 -05:00
Rapptz b9a99238e8 [commands] Add Command/Cog.has_error_handler
This allows querying the state without relying on internal undocumented
attributes.
2021-01-15 06:00:45 -05:00
Nihaal Sangha 69bdc3a184 Change copyright year to present 2021-01-15 05:28:11 -05:00
jack1142 ed2650f786 Fix documented type of Command.usage 2021-01-14 03:17:18 -05:00
Sebastian Law e9e81d1a55 [commands] fully remove command when CommandRegistrationError is raised for alias 2020-12-29 08:24:54 -05:00
Dan Hess faffc8eeb2 [commands] Correct concurrency never releasing during prepare call 2020-12-26 20:58:58 -05:00
Rapptz f9dd200314 [commands] max_concurrency comes before cooldowns
Fix #6172
2020-12-17 22:21:45 -05:00
Michael 93fa46713a Fix and add documentation 2020-09-23 03:19:35 -04:00
Josh f8a7d3fc54 [commands] Fix exception raised in Command invoke hooks. 2020-09-09 19:47:05 -04:00
Skye Im af88fc19b3 [commands] Update Bot.command() decorator docs 2020-09-07 22:29:02 -04:00
Nadir Chowdhury 367c4b5fd2 [docs] remove unresolved doc refs, fix attribute ref 2020-09-07 22:25:11 -04:00
khazhyk 6349d37a97 [commands] add require_var_positional 2020-09-07 22:24:48 -04:00
Rapptz 0a7e2f7c2f [commands] BadBooleanArgument -> BadBoolArgument 2020-09-04 08:47:07 -04:00
Simon Beal 6ebd2e13a1 [commands] Add subclasses of BadArgument for converters 2020-09-04 08:45:29 -04:00
Rapptz 4203e7a5a8 [commands] Use edited timestamp if provided for cooldown timing 2020-08-25 23:15:26 -04:00
Dan Hess 3a9fd00a1a [commands] Provide a way to retrieve time left for a cooldown 2020-08-05 21:37:08 -04:00
Rapptz 09f432016c [commands] Restart subcommand_passed chain on invoke
Fix #5198
2020-08-05 08:36:45 -04:00
jack1142 901290c8a2 [commands] GroupView.get_command shouldn't raise errors for empty names 2020-07-22 23:16:43 -04:00
jack1142 84098ed824 [commands] Add a new exception class for command registration errors 2020-06-28 03:48:07 -04:00
Sebastian Law b4b953bfc6 Fix various inconsistencies within the documentation (#5067) 2020-06-28 03:45:58 -04:00
Saphielle Akiyama 1e9937a234 Aliases passed as a list or as a tuple
Nothing too important, felt like some people would appreciate it;
2020-05-10 17:02:56 -04:00
MarkKoz 2653ae7599 [commands] Stop yielding duplicate commands from walk_commands 2020-04-06 04:52:53 -04:00
NCPlayz 1b0e806245 [commands] Implement commands.before/after_invoke 2020-04-04 02:57:20 -04:00
Rapptz bb1c1e9fa3 [commands] Raise when passing invalid permission keys in their checks 2020-02-02 19:11:50 -05:00
Karthikeyan Singaravelan 1b4cac92fc Fix warnings regarding invalid escape sequences. 2020-01-25 21:46:33 -05:00
Rapptz d9cd4a3561 [commands] Implement Command.__call__ 2020-01-21 04:27:20 -05:00