* Rename `bot.db` as `bot._config`
- Continues work towards strong version guarantees
- Added methods for cog use for a few things which were previously
only accessible via direct access.
- Retained private use in a few internal use locations, though most
methods were updated away from this.
- Updated documentation for shared api token users
* changelog
* more detail
* docstring fixes
* Apparently, I forgot to commit something I had locally
- + a copy/paste failue in the changelog
* *sigh*:
* *sigh*
* Add command to remove dead members from bank
* Add a global check
* Added a FIXME so `bank_local_clean` is updated once bulk-update is implemented
Added a brief warning to warn devs not to use the `_get_base_group` as it can mess up their config files
Removed a redundant existence check
* Updated commit to reflect changes requested in review
* Updated commit to reflect changes requested in review
* 🤦
* Return command to run with user id so we don't worry about safeguarding the command agaisn't invalid formats
* Braaaainnn
Removed aliases that used old naming scheme
* TL:DR Added global bank support, and rework permissions
Renamed `bank_local_clean` to `bank_prune`
Added support for global banks to `bank_prune`
`bank_prune` will now raise `BankPruneError` if trying to prune a local bank and `guild` is not supplied
Renamed `cleanup` subgroup to `prune`
`prune` subgroup will have 3 commands:
`user` : Deletes the bank account for the specified member : Accepts `Union[discord.Member, discord.User, int]`
`global` : Prune global bank accounts for all users who no longer share a server with the bot
`local` : Prune local bank accounts for all users who are no longer in the guild
Changed check for `prune` subgroup to be `@check_global_setting_admin()`
[p]bank prune local : Can be run by Guild owners only
[p]bank prune global : Can be run by Bot Owner only
[p]bank prune user : Can be run by Admins, Guild owners and Bot Owner
* Yikes ... Updated kwarg name
* Fixed unexpected unindent: docstring of redbot.core.bank.bank_prune:14:Field list ends without a blank line
* ...
* 3rd time lucky?
* 4th time lucky?
* Fix Docstring
* Initial commit to address review by Flame
* Updated code to reflect Flame's comments
* Skip pruning of unavailable guilds
* Fixed typo in string
* *sigh* black is the bane of my existence
* addressed Flames commends
Fixed [p]bank prune user, When run via DM it will now return an error message to the user (Thanks jack1142)
* Time to get some sleep
* 'DM' > 'DMs' in string
* Add towncrier entries
Signed-off-by: Draper <guyreis96@gmail.com>
* Update to reflect Flame's review
Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>
* Catch discord.errors.Forbidden when DMing a user the invite message
Uses the same error message as `[p]help`
* Create 2948.bugfix.rst
* You saw nothing
* Removes `MAX_BALANCE` from bank, user `bank.get_max_balance()` now
`[p]bankset maxbal` can be used to set the maximum bank balance
Signed-off-by: Guy <guyreis96@gmail.com>
* Removes `MAX_BALANCE` from bank, user `bank.get_max_balance()` now
`[p]bankset maxbal` can be used to set the maximum bank balance
Signed-off-by: Guy <guyreis96@gmail.com>
* Removes `MAX_BALANCE` from bank, user `bank.get_max_balance()` now
`[p]bankset maxbal` can be used to set the maximum bank balance
Signed-off-by: Guy <guyreis96@gmail.com>
* Rename method 🤦
Signed-off-by: Guy <guyreis96@gmail.com>
* Updated this to be aware of #2925
Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>
* Addressed Flames review + Fixed 1 bug in errors.py + `[p]leaderboard` and `[p]bank balance` will set the users balance to max balance if the bank maxbal is lower than the previous user balance
Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>
* Missed this clarification
Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>
* address Flames review
Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>
* Fixed `[p]local start`
Playlist picker auto selects if theres just 1 playlist found
`[p]queue cleanself` added
Signed-off-by: Guy <guyreis96@gmail.com>
* Black.... you are supposed to trigger before commits
Signed-off-by: Guy <guyreis96@gmail.com>
* Added `BalanceTooHigh` to the docstrings of `bank.transfer_credits()`
Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>
* Bring this in line with #2926 to reduce conflicts,`is_global()` already is called inside `get_currency_name` and as such it does not need to be called outside
Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>
* PostgreSQL driver and general drivers cleanup
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Make tests pass
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Add black --target-version flag in make.bat
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Rewrite postgres driver
Most of the logic is now in PL/pgSQL.
This completely avoids the use of Python f-strings to format identifiers into queries. Although an SQL-injection attack would have been impossible anyway (only the owner would have ever had the ability to do that), using PostgreSQL's format() is more reliable for unusual identifiers. Performance-wise, I'm not sure whether this is an improvement, but I highly doubt that it's worse.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Reformat
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Fix PostgresDriver.delete_all_data()
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Clean up PL/pgSQL code
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* More PL/pgSQL cleanup
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* PL/pgSQL function optimisations
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Ensure compatibility with PostgreSQL 10 and below
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* More/better docstrings for PG functions
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Fix typo in docstring
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Return correct value on toggle()
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Use composite type for PG function parameters
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Fix JSON driver's Config.clear_all()
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Correct description for Mongo tox recipe
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Fix linting errors
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Update dep specification after merging bumpdeps
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Add towncrier entries
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Update from merge
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Mention [postgres] extra in install docs
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Support more connection options and use better defaults
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Actually pass PG env vars in tox
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Replace event trigger with manual DELETE queries
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
Stop saving json files with 4 indents, this will significantly reduce file size and improve `.set()` performance for config saves when using the JSON driver.
Signed-off-by: Draper <guyreis96@gmail.com>
* I know this needs a changelog entry and docs still
* update tests for new behavior
* update docs, filter; add changelog
* Ready for review
* stop fetching the same Audit logs when the bot is the mod
* I forgot to press save
* fix a comprehension
* Fix AttributeError
* And the other place that happens
* timing fixes
* [i18n] Update translation catalogs
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Install redgettext 3.1 in travis crowdin deployment
Last time the catalog templates were updated, redgettext 3.0 was used. I'd rather Travis didn't upload them after extracting with an older version.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Make Requires.verify() wait until rules are loaded
Also ensures `Requires` objects are reset when unloaded, particularly in case a `Command` object manages to stay in memory between cog unload and load, and its permissions rules change between those events.
Also, this PR re-ordered some of the event loop policy stuff, because it was required that the event loop policy be set before creating any `Requires` objects. This may or may not have an effect on other `get_event_loop()` calls elsewhere (either in our code, a dependency's, or asyncio's). Either way, these effects would be a *correction*, and any bugs that arise from it are likely to have been occurring silently beforehand.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Remove calls to `remove_listener()` in permissions
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Fix adding rules for permissions cog/commands itself
Also addresses feedback
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Clean up indentation when setting uvloop policy
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Use `set(walk_commands())` to traverse `Group` subcommands
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* [ModLog] Prevent duplicate kwarg error
The `name` key used to be set in the Config for casetypes.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Don't mutate `data` argument
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This was causing a KeyError to be raised whenever a key containing $ or . was part of the identifiers path, even if the value was actually in the dict.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* [Context] Adds react_quietly method to context
This allows developers to emojis to command messages
This is a modified version of tick()
It accepts True/False for Tick/Cross emoji and in addition to that any other emoji the bot can see
* Removed True/False support from react quietly
* Stopped catching InvalidArgument on react_quietly so that is propagated to devs
* [Core] Fix user output on cog load/reload
- Properly fixes the load/reload exception handling
- Fixes some i18n use here to not make assumptions about other
languages pluralization rules.
* Fix some typos
* Address Flame's Feedback
* It's important to save before committing ...
* formatting
* Fix some formats...
* Fix duplicate commands in fuzzy help
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
* Use help command's filter for all fuzzy
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
### Replacement for pipenv's environment setup
First of all, there's a new Make recipe for all devs and contributors on both Windows and Posix, `make setupenv`, which is kind of a replacement for `pipenv install --dev`. It creates a virtual environment in `.venv` using the inbuilt `venv` module, clearing out any existing virtual environment if needed first. Then it installs all dev dependencies using our new `dev-requirements.txt` file. `CONTRIBUTING.md` has been updated to reflect all of this.
### Dependency version bumping tool
Secondly, I've added a python script, `tools/bumpdeps.py` to help with bumping dependency versions. It has its own Make recipe too, `make bumpdeps`. This script won't work on Windows (yet). It reads the `tools/primary_deps.ini` file, which contains the primary requirements of Red and its extras with loose version specifiers, and outputs all pinned dependencies, in `setup.cfg` format. It's not a foolproof dependency resolver, it's quite simple, but it's bound to help out a lot. It'll try to give warnings if there might be a version conflict, but updating `setup.cfg` with its output and then doing `pip install -r dev-requirements.txt` will allow pip to issue warnings if something is conflicting.
So to add a new dependency, add it to `tools/primary_deps.ini` in the appropriate place, and either use `make bumpdeps` to completely update all dependencies, or simply add it to `setup.cfg` manually with its sub-dependencies, and all versions pinned.
### Sphinx 2.1.2 (docs changes)
The sphinx update brought along the ability to disable type annotations being rendered in function and method signatures, and I have gladly gone and done that. Type annotations should already be specified under the "Parameters" section, and the way sphinx renders them in function signatures makes them much harder to read.
Also, documented classes will now display what classes they inherit from.
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
Modlog was the biggest culprit for seriously large documents in the MongoDB backend, since it stored all cases as nested dicts in the guild scope. So, for example, on the Fortnite server, the guild document for Kowlin's bot had exceeded 8MB.
This commit gives each case its own document. It also does the same for casetypes. Not only does it remove the possibility of the document exceeding the maximum size in MongoDB, it's also just more efficient for all backends.
Other misc changes: Fixed a bunch of type-hints, and also added more support for when an object related to a case (user, moderator, channel etc.) can't be found (because it was deleted or something rather)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>