45 Commits

Author SHA1 Message Date
Michael
93fa46713a
Fix and add documentation 2020-09-23 03:19:35 -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
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
Rapptz
02397306b2 Drop superfluous zero in version related changes in the documentation 2020-01-21 03:47:56 -05:00
Rapptz
08c90668cd [commands] Be more clear in the default error for MaxConcurrencyReached 2020-01-21 03:34:18 -05:00
Rapptz
bf84c63396 [commands] Add max_concurrency decorator 2020-01-21 03:26:41 -05:00
Rapptz
6071607176 Bump copyright year to 2020
Closes #2510
2020-01-19 20:03:00 -05:00
Rapptz
ae3dac0d59 [commands] Add check_any check to OR together various checks 2020-01-06 22:03:56 -05:00
Benjamin Mintz
0a21591d0c [commands] Don't raise ExtensionNotFound for ImportErrors in modules
Now loading an extension that _contains_ a failed import will fail
with ExtensionFailed, rather than ExtensionNotFound.
2019-06-29 19:15:05 -04:00
NCPlayz
3c9bcc2851 Improve documentation 2019-06-07 19:27:46 -04:00
Rapptz
5a7b5cd14b [commands] Allow passing of a message to NoPrivateMessage again.
Prevents an accidental breaking change.
2019-04-20 17:28:44 -04:00
Rapptz
919dbcafb3 Consistent use of __all__ to prevent merge conflicts. 2019-04-20 17:20:58 -04:00
Rapptz
6620fcc038 [commands] Consistently mention inheritance of exceptions. 2019-04-20 16:59:54 -04:00
Vexs
bb3ebc0ebc [commands] Add custom exception classes for built-in checks
Added:
* MissingRole
* BotMissingRole
* MissingAnyRole
* BotMissingAnyRole
2019-04-20 16:45:37 -04:00
Dante Dam
aabbd5a446 [commands] Added dm_only check
Raises PrivateMessageOnly on failure.
2019-04-11 00:02:22 -04:00
Rapptz
ef0b2a1092 [commands] Properly name heading for ExtensionError 2019-04-10 00:59:02 -04:00
Rapptz
c30a366106 Try to consistently use "inherit" vs "derive" in documentation. 2019-03-19 09:23:12 -04:00
Rapptz
d9e54d7dd3 [commands] Redesign extension exception flow.
Instead of raising a whole variety of exceptions, they are now wrapped
into ExtensionError derived classes.

* ExtensionAlreadyLoaded
	* Raised when an extension is already loaded in Bot.load_extension
* ExtensionNotLoaded
	* Raised when an extension is not loaded, e.g. Bot.unload_extension
* NoEntryPointError
	* Raised when an extension does not have a `setup` function.
* ExtensionFailed
	* Raised when an extension's `setup` function fails.
* ExtensionNotFound
	* Raised when an extension's module import fails.
2019-03-19 09:23:11 -04:00
Rapptz
560783c3d2 [commands] Separate view parsing errors from BadArgument.
This causes them to be raised from a new exception named
ArgumentParsingError with 3 children for ease with i18n. This is
technically a breaking change since it no longer derives from
BadArgument, though catching UserInputError will prevent this change
from affecting the user.
2019-03-12 05:27:34 -04:00
Dante Dam
9656a21ebe Bumped copyright years to 2019. 2019-01-28 22:22:50 -05:00
Rapptz
418048b98a [commands] Fix up Greedy documentation a bit. 2018-09-24 04:22:09 -04:00
BeatButton
a4d1599ce9 Change docstrings to raw-strings 2018-09-14 22:55:27 -04:00
Hornwitser
c8b49d37be [lint] Fix incorrect and inconsistent whitespace
Adjust whitespace to be consistent with the rest of the library.
2018-08-22 21:43:53 -04:00
Rapptz
da5776a358 [commands] Make ConversionError have the original error as an attribute 2018-07-20 05:54:51 -04:00
Rapptz
92dde9aef9 [commands] Add support for typing.Union as a converter 2018-07-20 05:51:43 -04:00
khazhyk
2321ae8d97 [commands] raise ConversionError on Converter error
This assumes that a Converter class raising non-CommandError
is a programmer error. Makes this type of error easier to
disambiguate from a generic BadArgument.
2018-07-20 04:14:20 -04:00
Tobotimus
3112e1c17e Add intersphinx 2018-01-06 17:23:59 -05:00
khazhyk
0ef866a704 [commands] Fix MissingRequiredArgument param handling
Documentation was incorrect, and we were throwing
away the param we were passing.
2018-01-06 17:23:58 -05:00
ReinaSakuraba
8646bddc90 [commands] Add MissingPermissions and BotMissingPermissions 2017-08-30 23:20:55 -04:00
Rapptz
b44bba6ee6 First pass at documentation reform. 2017-05-12 20:14:34 -04:00
Rapptz
5c5e7ae1d6 [commands] Add is_owner check and Bot.is_owner. 2017-03-27 06:55:21 -04:00
Rapptz
afb64fb5e3 [commands] Remove Command.no_pm for commands.guild_only check.
This is a breaking change. The original purpose of no_pm has been
mainly a legacy aspect. They came from a time before checks were a
generalised concept and were never removed. A check is the proper way
to do its behaviour.
2017-03-26 21:41:34 -04:00
Rapptz
7bc3750c27 [commands] Add param attribute to MissingRequiredArgument
This should allow easier querying on what argument is missing.

Fixes #470.
2017-02-12 13:53:49 -05:00
Rapptz
ff9f5749e1 Update copyright year to 2017. 2017-01-20 23:19:19 -05:00
Rapptz
cd0de57d13 [commands] Implement a command cooldown system.
The way the command cooldown works is using a windowed way of doing it.
That is, if we have a cooldown of 2 commands every 30 seconds then if we
do a single command, we have 30 seconds to do the second command or else
we will get rate limited. This more or less matches the common
expectations on how cooldowns should be.

These cooldowns can be bucketed up to a single dimension of depth for
a per-user, per-guild, or per-channel basis. Of course, a global bucket
is also provided. These cannot be mixed, e.g. no per-channel per-user
cooldowns.

When a command cooldown is triggered, the error handlers will receive a
an exception of type CommandOnCooldown with proper information regarding
the cooldown such as retry_after and the bucket information itself.
2016-07-22 18:05:38 -04:00
Rapptz
5010e7dc55 [commands] Add UserInputError into the exception hierarchy.
This is for exceptions that are inherently based on user errors and not
permission based. e.g. passing incorrect number of arguments, too many
arguments, or an invalid argument. CommandNotFound is not classified
under this since it isn't inherently a user input error in all cases.

Some invalid commands can simply be due to an odd bot prefix. It would
also diminish the usefulness of the new parent class if CommandNotFound
was included.
2016-07-21 23:53:16 -04:00
Rapptz
324d10c9d9 [commands] Add Command.ignore_extra attribute to ignore extra arguments
This allows you to strictly require a number of arguments. The default
behaviour in this case is still `True`, since it would be a breaking
change otherwise and is a sane default. However if someone would want
to set this to `False`, they would receive an exception of type
`TooManyArguments` if too many arguments are passed to a command.

Hopefully this removes the uses of `ctx.message.content == 'stuff'`
inside commands.
2016-06-20 21:38:17 -04:00
Rapptz
5f9ed8c9d2 [commands] Make the CommandError required argument optional again. 2016-06-10 23:50:17 -04:00
Rapptz
74cfc53bc8 [commands] Make it so CommandError does not contain @everyone mentions.
Mitigates some permission elevation issues.
2016-06-10 20:40:35 -04:00
Rapptz
43bbecd519 [commands] Exceptions raised while invocation raise CommandInvokeError.
This change should make it a bit more intuitive to get the original
exception without having the gotcha of checking ``isinstance`` inside
the error handler.
2016-06-10 20:32:05 -04:00
Rapptz
25588955e4 [commands] Add a way to enable or disable certain commands. 2016-01-07 17:59:26 -05:00
Rapptz
51186c3ca4 [commands] Add CommandNotFound error. 2016-01-05 01:11:52 -05:00
Rapptz
59ca5ec386 Initial implementation of commands extension module. 2016-01-04 22:22:52 -05:00