79 Commits

Author SHA1 Message Date
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
Rapptz
20ddc9f14f [commands] Remove send_ utility functions. 2017-01-03 09:52:04 -05:00
Rapptz
d1d54a468a Rename Server to Guild everywhere. 2017-01-03 09:51:54 -05:00
Rapptz
20251c54a7 [commands] Bot skip check now works with the new __eq__ changes. 2017-01-03 09:51:51 -05:00
PapyrusThePlant
31cd9ad37a [commands] Bugfix on the teardown function call. 2017-01-01 01:49:10 -05:00
Rapptz
bed2e90e82 Properly propagate loop. Fixes #420. 2016-12-21 00:06:19 -05:00
Rapptz
00e30f3106 [commands] Shield against dictionary resize in Bot.close 2016-12-17 21:18:48 -05:00
Rapptz
fc1a7183a0 [commands] Unload all cogs when gracefully exiting bot. 2016-12-17 14:47:29 -05:00
Rapptz
6d88024f0f [commands] Add special extension function 'teardown' for clean-up.
This is to support people who want to clean up some external resource
that the extension is maintaining outside of a cog, where __unload
should be used instead.

The callable is the antipode of 'setup' and takes the same sole
parameter, the bot, after all commands, events, and cogs have been
unloaded.

Fixes #405.
2016-12-17 14:15:11 -05:00
Rapptz
bafaf72c89 [commands] Unload all extensions when gracefully closing bot. 2016-12-17 14:15:10 -05:00
Rapptz
967d43c35b [commands] Allow coroutine functions in Bot.command_prefix 2016-09-17 15:01:56 -04:00
Rapptz
1e9251cfef [commands] Delete module when it does not have a setup function. 2016-08-10 15:11:45 -04:00
Rapptz
cd87f247d3 [commands] Make Bot.check decorator an actual decorator. 2016-07-08 04:29:11 -04:00
PapyrusThePlant
1aaeeff02b [commands] Added missing parenthesis in examples 2016-07-08 04:29:05 -04:00
Rapptz
adbf2c720f [commands] Add the concept of global checks.
Global checks are checks that are executed before regular per-command
checks except done to every command that the bot has registered. This
allows you to have checks that apply to every command without having to
override `on_message` or appending the check to every single command.
2016-06-19 22:15:11 -04:00
Rapptz
6f173cc095 [commands] Add delete_after keyword argument to utility functions.
This includes things like `Bot.say`, `Bot.upload`, `Bot.whisper`,
and `Bot.reply`.
2016-06-19 19:43:49 -04:00
Rapptz
4dbac9423d [commands] Only show CommandNotFound on non-empty commands. 2016-06-14 01:35:35 -04:00
Rapptz
bde266bbb9 [commands] Fix @everyone elevation in the default help command. 2016-06-10 21:31:11 -04:00
Rapptz
a0f37f8e85 [commands] Fix issue with proper local error handlers not beign called. 2016-06-10 01:07:03 -04:00
Rapptz
b9c7b05176 [commands] Unify Command.handle_local_error into general dispatcher. 2016-06-05 00:35:27 -04:00
Rapptz
37dfe38af5 [commands] Fix bug where Context.command would not update. 2016-06-04 22:29:50 -04:00
Khazhismel Kumykov
33a69681fc [commands] Dispatch command_error on command exec error.
Provide fallback on_command_error - will only fire if no cog handlers and
no local handler.
Propagate exceptions in checks and argument parsing to bot.
2016-06-04 21:22:10 -04:00
Rapptz
20e86973ea [commands] Delete frame objects when done using them. 2016-05-31 23:22:53 -04:00