101 Commits

Author SHA1 Message Date
Rapptz
e12db3a25d [commands] Add call_once keyword-only parameter for Bot.remove_check
Technically a breaking change. This is to be a parallel with the
Bot.add_check interface.
2018-10-11 02:52:26 -04:00
MusicOnline
9af0e54cd3 Correct ClientException message raised in invocation hooks.
For when the hooks are not coroutines.
2018-09-20 23:43:07 -04:00
BeatButton
a4d1599ce9 Change docstrings to raw-strings 2018-09-14 22:55:27 -04:00
zephyrkul
b9ef80b0d0 [commands] Prepend mention prefixes in commands.when_mentioned_or 2018-08-28 23:50:57 -04:00
Ben Mintz
be7ea2678b Bot.unload_extension: don't remove commands from no module
Fixes unload_extension in the case of a command added via eval
2018-08-22 21:56:41 -04:00
Hornwitser
3679819c53 [lint] Remove unnecessary lambdas
Lambdas of the form `lambda x: func(x)` are redundant.
2018-08-22 21:43:52 -04:00
Hornwitser
d58fc0ccee [lint] Remove unused imports
Left over from various refactoring and rewrites.
2018-08-22 21:43:50 -04:00
Rapptz
aa7c5c3ec1 [commands] Ignore bots from Bot.process_commands by default. 2018-08-22 21:06:09 -04:00
Hornwitser
a93c3d931c [commands] Change command_prefix behaviour
Change the behaviour of handling iterable command_prefix types to not
silently ignore falsy prefixes and unify behaviour for all iterable
types.  Add special handling of a possible TypeError in both get_prefix
and get_context for when the prefix is a different type from what is
expected.
2018-06-29 21:48:30 -04:00
Rapptz
607771c4f4 Fix Bot.get_prefix second parameter breaking. 2018-06-10 18:41:36 -04:00
Rapptz
f25091efe1 Drop support for Python 3.4 and make minimum version 3.5.2. 2018-06-10 18:10:00 -04:00
Rapptz
871a262ee3 [commands] Add ability to have case insensitive commands.
This is powered by a dict-like class for the people who want to opt-in
to the performance downgrade for usability for majority English
speaking users.

Since it is slower than the regular dict due to the excessive calls to
str.lower along with the possibilities of gotchas for other languages
outside of English, this is kept as False for the default case.
2018-03-06 00:37:12 -05:00
Tobotimus
3112e1c17e Add intersphinx 2018-01-06 17:23:59 -05:00
S Stewart
89f9009a28
[commands] Fix minor spelling mistake 2017-11-20 09:00:32 -06:00
Rapptz
e24914be0b [commands] Fix NameError when given an invalid prefix.
Closes #775
2017-09-12 04:22:13 -04:00
Rapptz
fce2ef5534 [commands] Raise when an invalid prefix is given.
Fixes #712
2017-08-15 06:12:09 -04:00
Rapptz
bcaee518a1 [commands] Remove support for pass_context=False in Command. 2017-07-18 17:58:38 -04:00
Rapptz
2f97678a79 First pass at commands narrative documentation. 2017-07-08 00:28:23 -04:00
khazhyk
fc22d288be [commands] unload cog submodules
When unloading cogs, currently we do not remove submodules from
sys.modules, meaning they will not be reloaded. Removing here
makes new imports reload from file. Of course, any already imported
modules will still hold a reference to the old module, since they
will not re-import it, and will not be forcably unloaded.
2017-07-07 18:02:29 -04:00
khazhyk
6c01250c39 [commands] fix unloading incorrect cogs
unload_extension would incorrectly unload cogs/listeners
of other extensions if the name of one was a prefix of
another.
2017-07-03 20:56:04 -07:00
khazhyk
bca72e64d6 [commands] clean up remove_cog documentation
remove_cog always returns None, even if the cog is found.
2017-07-03 19:02:00 -07:00
Rapptz
0b9d402272 [commands] Improve commands.when_mentioned_or documentation. 2017-07-01 16:32:36 -04:00
Rapptz
717f11d635 [commands] Add Bot.check_once for a global check that is called once.
There is a counterpart for this in cogs, called __global_check_once.
This allows for predicates that would filter a command globally that
do not necessarily require rechecking in the case of e.g. the help
command such as blocking users or blocking channels.
2017-06-20 23:41:13 -04:00
Rapptz
e62e2c7cc6 [commands] Fix cog error detection in the default global error handler. 2017-06-13 23:51:11 -04:00
Rapptz
7d6435fa9c [commands] Don't display default error handler if a cog local exists. 2017-06-12 17:44:05 -04:00
Rapptz
83dc93559c [commands] Add docstrings for extension loading. 2017-06-05 22:55:57 -04:00
Rapptz
f588876587 Use Python3Lexer instead of PythonLexer for pygments. 2017-05-22 07:21:23 -04:00
Rapptz
c3e39cd722 [commands] Fix Context.command_failed from being incorrect.
When used, it would be set to False after the invoke was done. Ideally
it should report to False during invoke but True during any error
case.
2017-05-18 20:48:38 -04:00
Rapptz
b44bba6ee6 First pass at documentation reform. 2017-05-12 20:14:34 -04:00
Rapptz
8ef984746a [commands] Fix default error handler to work with the switch. 2017-05-10 19:36:46 -04:00
Rapptz
a2c9cefac9 [commands] Re-order error handler arguments.
They now have Context as the first argument to be consistent with other
context-passing functions.
2017-05-10 17:49:42 -04:00
Rapptz
37681dd0ea [commands] Fix lack of space in when_mentioned 2017-04-24 00:23:23 -04:00
Rapptz
c005ef5d44 [commands] Make when_mentioned always have both mention formats.
This will allow it to work in mobile clients which don't respect the
<@!id> format in case of nicknames.
2017-04-24 00:13:27 -04:00
Rapptz
b6ac856868 [commands] Allow loading cogs from folders.
Internally, instead of using module objects just use the `__module__`
attribute which is the same thing. From preliminary testing this seems
to work fine with both regular one-file-per-cog approaches and the
folder cog approach.

Fixes #126.
2017-04-21 18:57:28 -04:00
Rapptz
5c5e7ae1d6 [commands] Add is_owner check and Bot.is_owner. 2017-03-27 06:55:21 -04:00
Rapptz
54fdafb792 [commands] Add BotBase.get_cog_commands to get all a cog's commands.
Self-explanatory. This should help create help commands for a cog
more easily.
2017-03-21 00:46:12 -04:00
Rapptz
fe588a4d52 [commands] Change GroupMixin.commands to all_commands
This is a breaking change as GroupMixin.commands now returns a set
of unique Command objects.
2017-03-21 00:46:12 -04:00
Rapptz
9cb89f019e [commands] Register cog listeners with the name of the attribute. 2017-02-22 20:11:01 -05:00
Rapptz
47ef657fbd Implement async checks. Fixes #380. 2017-02-12 12:13:23 -05:00
Rapptz
1c49374210 [commands] Implement before and after invoke command hooks.
Fixes #464.
2017-01-27 18:53:21 -05:00
Rapptz
8fa50a8f3e [commands] Add Context.command_failed attribute. 2017-01-27 17:14:22 -05:00
Rapptz
0e1bd1647e [commands] Rename __check to __global_check for cogs. 2017-01-26 05:31:11 -05:00
Rapptz
4016154529 [commands] Allow customising the Context class in get_context. 2017-01-26 05:05:15 -05:00
Rapptz
234fd5180f Optimise attribute access when dispatching. 2017-01-25 05:31:53 -05:00
Rapptz
ff9f5749e1 Update copyright year to 2017. 2017-01-20 23:19:19 -05:00
Rapptz
ea72d5e63d [commands] Guarantee that local error handler is called before generic. 2017-01-15 21:55:50 -05:00
Rapptz
ce9d5b4f4a [commands] Split process_commands into lower level bits. 2017-01-14 19:17:08 -05:00
Rapptz
695b62ccd3 [commands] Make Command a descriptor for #426. 2017-01-13 20:34:00 -05:00
Rapptz
d22d8cc430 [commands] Add AutoShardedBot counterpart to AutoShardedClient. 2017-01-08 04:50:59 -05:00
Rapptz
496f5d0472 [commands] Fix help command from not working with recent changes. 2017-01-03 09:52:12 -05:00