* Uses classmethods to create predicates
* Classmethods allow using a combination of different parameters to describe context
* Some predicates assign a captured `result` to the predicate object on success
* Added `ReactionPredicate` equivalent to `MessagePredicate`
* Added `utils.menus.start_adding_reactions`, a non-blocking method for adding reactions asynchronously
* Added documentation
* Uses these new utils throughout the core bot
Happened to also find some bugs in places, and places where we were waiting for events without catching `asyncio.TimeoutError`
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
API changes:
- Cogs must now inherit from `commands.Cog` (see #2151 for discussion and more details)
- All functions which are not decorators in the `redbot.core.checks` module are now deprecated in favour of their counterparts in `redbot.core.utils.mod`. This is to make this module more consistent and end the confusing naming convention.
- `redbot.core.checks.check_overrides` function is now gone, overrideable checks can now be created with the `@commands.permissions_check` decorator
- Command, Group, Cog and Context have some new attributes and methods, but they are for internal use so shouldn't concern cog creators (unless they're making a permissions cog!).
- `__permissions_check_before` and `__permissions_check_after` have been replaced: A cog method named `__permissions_hook` will be evaluated as permissions hooks in the same way `__permissions_check_before` previously was. Permissions hooks can also be added/removed/verified through the new `*_permissions_hook()` methods on the bot object, and they will be verified even when permissions is unloaded.
- New utility method `redbot.core.utils.chat_formatting.humanize_list`
- New dependency [`schema`](https://github.com/keleshev/schema)
User-facing changes:
- When a `@bot_has_permissions` check fails, the bot will respond saying what permissions were actually missing.
- All YAML-related `[p]permissions` subcommands now reside under the `[p]permissions acl` sub-group (tbh I still think the whole cog has too many top-level commands)
- The YAML schema for these commands has been changed
- A rule cannot be set as allow and deny at the same time (previously this would just default to allow)
Documentation:
- New documentation for `redbot.core.commands.requires` and `redbot.core.checks` modules
- Renewed documentation for the permissions cog
- `sphinx.ext.doctest` is now enabled
Note: standard discord.py checks will still behave exactly the same way, in fact they are checked before `Requires` is looked at, so they are not overrideable.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* [V3 CustomCom] Custom Command Parameters
Allows specifying more parameters for CC's via {0}, {1}, etc. that will be filled by the user invoking the CC. Python-style type hinting and attribute access is also allowed for Discord and builtin types.
> [p]cc add simple greet Hi, {0.mention:Member}!
> ...
> [p]greet zephyrkul
> Hi, @zephyrkul!
The bot will reply with the standard help messages if the cc is incorrectly executed.
> [p]greet me
> Member "me" not found
* black formatting
* check command failure
Only call the custom command if the faked command succeeded.
* misc fixes
1) don't str.strip all the time, it's not family-friendly and doesn't match transform_parameter
2) transform_arg now actually returns strings in every case
3) improve prepare_args parsing security
4) help parameters will show what type they expect
5) make linter less angery
* customcom documentation
I hate rst
* don't require repeated type hinting
If a parameter was type hinted previously, don't require it again.
Ex: `{0.display_name:Member}#{0.discriminator}` is now possible.
* add cog_customcom.rts to index
I despise rst
* don't enforce order
Allow type hinting and attribute access to be in either order.
Ex. `{0:Member.mention}` is now valid.
* clean up on_message
We're building context anyway, may as well use it.
* [doc] correct cog name
Cog class is named CustomCommands, not CustomCom
* minor on_message optimization
only build context if it's needed
* update cc_add docstring
Old one wasn't user-friendly. Replaced with a link to the new docs.
Link will not function until PR is merged and docs refreshed.
* [doc] change repeat to say
repeat is an audio command, use say in the example instead
* compare ctx.prefix to None
allows for null prefixes, which is a bad idea but who am I to judge
* address review
* raise error on conflicting colon notation
bugfix I was working on but failed to actually commit
* Cleanup quotes in cogs
* More quote cleanup that I missed
fixed a little bit of grammar here and there as well.
* [V3 Warnings] Change allowcustomreasons docstring
To help not confuse users who would believe that the command would use allow or disallow.
* Run black reformat
* Update travis to not sip pipfile lock
update pipfile dependencies
additional black formatting pass to conform to black 18.5b
* .
* pin async timeout until further discussion of 3.5 support
* .
* Framework for internationalised command help
* Translator for class docstring of cog
* Remove references to old context module
* Use CogManagerUI as PoC
* Replace all references to RedContext
* Rename CogI18n object to avoid confusion
* Update docs
* Update i18n docs.
* Store translators in list instead of dict
* Change commands module to package, updated refs in cogs
* Updated docs and more references in cogs
* Resolve syntax error
* Update from merge