194 Commits

Author SHA1 Message Date
Rapptz
a7f846b37f [commands] Fix Command.root_parent not properly working. 2017-07-19 05:14:23 -04:00
Rapptz
bd4505fec5 [commands] Restart the StringView properly in Context.reinvoke.
The old code for some reason assumed that the length of the command
would be 1. This is because when I tested this I would use single
letter command names and it would "just work" when in reality it was
completely incorrect.

A reminder to thoroughly test instead of just fitting something to work
2017-07-18 18:02:06 -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
ce34713c45 [commands] Do not take up 'command' keyword-argument in Context.invoke.
It was annoying when commands would have a keyword-only argument
named 'command', such as a help command or a disable command.
2017-06-27 04:58:20 -04:00
Rapptz
ad20e3066e [commands] Add parameter that failed in fall-back BadArgument error. 2017-06-26 18:13:46 -04:00
Rapptz
3618f51f97 [commands] Ensure that Context.command is the command in Command.can_run
Previously, Context.command was not guaranteed to be the actual command
being checked if it can run. This could be troublesome when
implementing help commands or when using the default help command.

This new change allows at least for the guarantee that Context.command
to be technically correct in Command.can_run.
2017-06-21 02:30:24 -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
7d001ef46e [commands] Try to use the proper name when conversion fails. 2017-06-17 21:16:10 -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
5e6491c3fe [commands] Allow inline advanced converters via classmethods.
That way you don't need to have, e.g. Foo and FooConverter and can
do it inline via Foo instead.
2017-06-01 03:32:18 -04:00
Rapptz
b2cf11fe9d [commands] Add escape_markdown parameter for clean_content. 2017-05-28 23:18:54 -04:00
Rapptz
093d888173 [commands] Fix EmojiConverter not working with underscore names. 2017-05-26 18:58:56 -04:00
Rapptz
f588876587 Use Python3Lexer instead of PythonLexer for pygments. 2017-05-22 07:21:23 -04:00
Rapptz
b81fbb5a7f [commands] Add Context.reinvoke and Command.root_parent
Context.reinvoke would be the new way to bypass checks and cooldowns.
However, with its addition comes a change in the invocation order of
checks, callbacks, and cooldowns. While previously cooldowns would
trigger after command argument parsing, the new behaviour parses
cooldowns before command argument parsing.

The implication of this change is that Context.args and Context.kwargs
will no longer be filled properly.
2017-05-19 21:33:39 -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
c1130d2879 [commands] Update check examples to work with rewrite. 2017-05-15 02:52:20 -04:00
Rapptz
b44bba6ee6 First pass at documentation reform. 2017-05-12 20:14:34 -04:00
Rapptz
d7478425ca [commands] Converter.convert is always a coroutine.
Along with this change comes with the removal of Converter.prepare and
adding two arguments to Converter.convert, the context and the argument.

I suppose an added benefit is that you don't have to do attribute
access since it's a local variable.
2017-05-10 21:30:41 -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
c20ba51e28 [commands] Export is_nsfw check. 2017-05-05 20:21:28 -04:00
Rapptz
c8937ed2aa [commands] Add is_nsfw check. 2017-05-01 22:36:22 -04:00
Rapptz
37681dd0ea [commands] Fix lack of space in when_mentioned 2017-04-24 00:23:23 -04:00
Rapptz
6188397fc9 [commands] Add Context.voice_client shortcut. 2017-04-24 00:17:04 -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
3e15f46dcf [commands] Bot.get_all_emojis no longer exists. 2017-04-12 05:00:50 -04:00
Rapptz
7da0884bfb [commands] Export missing built-in converters. 2017-04-12 04:46:53 -04:00
Rapptz
e1c32626ba [commands] Fix User converter not working with IDs. 2017-03-27 20:08:26 -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
9885a946e1 More robust cleanup for Client.run.
This should prevent asyncio.CancelledError from being propagated more
and suppressed "Task was destroyed but was pending!" warnings when
doing graceful closes outside of using a KeyboardInterrupt.

To make clean up a bit more robust, also add signal handlers
for POSIX systems.
2017-03-24 20:27:30 -04:00
Rapptz
31a7093433 [commands] Fix minor spacing issue in Command.signature 2017-03-21 15:36:52 -04:00
Rapptz
3087600c8d [commands] Add Command.signature
This replaces HelpFormatter.get_command_signature for the most part.
2017-03-21 00:46:13 -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
98cfb53d3b [commands] Add Context.me property. 2017-03-01 18:58:56 -05:00
Rapptz
9cb89f019e [commands] Register cog listeners with the name of the attribute. 2017-02-22 20:11:01 -05:00
Rapptz
c6d26216a6 [commands] Fix bad logic in command list filtering. 2017-02-18 02:39:03 -05:00
Rapptz
6166cbc2e7 [commands] Add commands.clean_content converter. 2017-02-13 22:15:39 -05:00
Rapptz
e10cae5dbc [commands] Allow converters to be instantiated.
This allows for you to create converters that can have varying
behaviour using the converter's __init__ instead of having to do a
meta-class based approach to get around the fact that __init__ is part
of the interface.

To make up for the lack of __init__, a new method Converter.prepare was
added to do the work that __init__ used to do.
2017-02-13 21:05:25 -05:00
Rapptz
b6bff5172a [commands] Remove Commands: if no commands can be run in help command. 2017-02-13 04:27:31 -05:00
Rapptz
bf11bb4b4f [commands] Add cog local error handlers via __error. 2017-02-12 15:48:18 -05:00