Resolves#2160.
Also resolves another issue where the bot will error out when getting the guild's invites when it doesn't have the Manage Server permission.
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>
Use `async with Lock` instead of deprecated `with await lock` usage.
Forces a file fsync prior and a directory fsync (where available) after rename to prevent issues with left behind temp files.
Also should clarify: this is not threadsafe. Comments were clarified, function names remain misleading.
If the member is in the guild, delegates to existing ban logic.
Additionally, check that we have ban perms prior to attempting to fetch the existing ban list.
Fixes#2127.
What's changed:
- Fixed issues mentioned on #2031
- Fuzzy help displays more like help manual
- Fuzzy help is easier and more flexible to use
- Fuzzy help string-matching ratio lowered to 80
- Help formatter is more extendable
- Help command has been optimized, cleaned up and better incorporates fuzzy help
- Added async_filter and async_enumerate utility functions because I was using them for this PR, then no longer needed them, but decided they might be useful anyway.
- Added `Context.me` property which is a shortcut to `Context.guild.me` or `Context.bot.user`, depending on the channel type.
Previously, when downloader was loaded, the RepoManager would spawn a task to load available repos. If one repo failed loading for some reason, the function would raise and the remaining repos would never be loaded, however downloader would still appear to load correctly.
This change handles exceptions better during repo loading, but also, if an unhandled exception is raised, downloader will fail to load as it should.
Also included, as requested in #1968, is the --recurse-submodules flag in cloning/pulling repositories.
This change resolves#1950.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Set 3.6.6 as minimum python version on Windows
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Conditional python_requires in setup.py
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Should probably add the comment too
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* [Downloader] Parse tree URLs when cloning repos
Signed-off-by: Toby <tobyharradine@gmail.com>
* Only match GitHub and GitLab URLs
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
* Just a test
* another test
* undoing my test
* First solution, style issue
* Works functionally, but there are is a minor style issue
* style fixed
* Revert README changes
* Use ProactorEventLoop on Windows
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Set the actual loop instead of the policy
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* more filters
* note to future people touching this
* chan mentions were almost missed...
* Swap strategies as the previous escaped the mention, while still pinging the user/role
* Correct minimum version
see #2092
While this is needed because of an import just for typing, I see no reason not to bump the minimum version since this is a minor version difference since this is several minor version behind the latest 3.6, and there have been both security and performance improvements since.
That said, we need to be testing on our lowest supported version to ensure we don't have this happen again, right now our tests run on whatever Travis grabs for 3.6, which I assume is 3.6.6, but could be wrong.
* Update other mentions of min version to 3.6.2