Commit Graph
468 Commits
Author SHA1 Message Date
Rapptz f176309179 [commands] Don't handle single quotes. 2018-03-20 03:25:40 -04:00
Rapptz d8a85f4898 [commands] Minor optimisations to unicode quote handling. 2018-03-06 01:16:00 -05:00
b-hodgesandRapptz ea061ef9b2 [commands] Added handling for unicode quotes 2018-03-06 01:11:36 -05: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
Eli ad7506050c [commands] Allow builtin unbound method converters 2018-02-10 22:07:44 -08:00
GorialisandRapptz 04d9dd9c0d Change PartialReactionEmoji to PartialEmoji, add a PartialEmojiConverter 2018-01-06 17:32:25 -05:00
TobotimusandRapptz 3112e1c17e Add intersphinx 2018-01-06 17:23:59 -05:00
khazhykandRapptz 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
Rapptz 3a8b97ffb0 [commands] Document that can_run can raise. 2017-12-29 06:00:25 -05:00
Rapptz e61ac8e60f [commands] Forbid passing a string to aliases in Command.
Fixes #974
2017-12-29 01:42:45 -05:00
Joshua Butt f5a443fa8f Add support for animated emoji to commands ext EmojiConverter 2017-12-22 14:59:21 +10:00
S StewartandGitHub 89f9009a28 [commands] Fix minor spelling mistake 2017-11-20 09:00:32 -06:00
Rapptz 9b4a2dc7cb [commands] Minor speed-up for the BucketType.guild case.
None case:
344ns ± 24.4ns -> 49.9ns ± 1.39ns

Valid case:
128ns ± 2.76ns -> 42.7ns ± 0.459ns
2017-10-08 07:57:58 -04:00
Rapptz 1bb7b6ff2d [commands] Make CooldownMapping.get_bucket take Message instead.
Requiring a full blown Context might be a bit overkill considering
we only use a single attribute from it.
2017-10-08 07:52:56 -04:00
MysterialPyandRapptz bae6f80327 [commands] Split Cooldown state processing to two different functions.
This allows us to check if we are rate limited without
creating a new cool-down window for the command.
2017-10-03 03:57:06 -04:00
Rapptz e614f6b4cd [commands] Add CategoryChannelConverter 2017-09-13 17:19:30 -04:00
Rapptz e24914be0b [commands] Fix NameError when given an invalid prefix.
Closes #775
2017-09-12 04:22:13 -04:00
ReinaSakurabaandRapptz 10696a275b [commands] Have (bot_)has_permissions provide better failure responses 2017-08-30 23:20:59 -04:00
ReinaSakurabaandRapptz 8646bddc90 [commands] Add MissingPermissions and BotMissingPermissions 2017-08-30 23:20:55 -04:00
Rapptz 63fcfa6d02 [commands] Add CooldownMapping.from_cooldown factory classmethod. 2017-08-27 16:59:04 -04:00
Rapptz 1c967e9a7c [commands] Export cooldown classes as well. 2017-08-27 16:55:23 -04:00
Rapptz fce2ef5534 [commands] Raise when an invalid prefix is given.
Fixes #712
2017-08-15 06:12:09 -04:00
Rapptz eb673ec2af [commands] Ensure no mentions escape clean_content
Some clever nicknames or role names would lead themselves to
resolving to pings.
2017-08-10 03:17:24 -04:00
Rapptz cb709cc9da [commands] Fix clean_content converter not properly escaping mentions.
In some cases, the Discord provided role_mentions and mentions array
would be empty, such as wrapping a mention with a backtick or
other frivolous characters. Since we want to completely nullify
mentions, we should not rely on the Discord provided arrays and instead
use and resolve the IDs from the content itself.
2017-08-10 02:46:00 -04:00
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
khazhykandRapptz 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
khazhykandGitHub 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