467 Commits

Author SHA1 Message Date
jack1142
59e7d063a0 [Tunnel] Add use_cached and images_only kwargs to files_from_attach (#2887)
* feat(tunnel): add `use_cached` kwarg

re #2885

* feat(tunnel): add `images_only` kwarg

re #2885

* chore(changelog): add towncrier entry
2019-09-28 17:28:14 -04:00
jack1142
6e3ccc1a21 [Commands] cls parameter can now be passed to group like in d.py (#2881)
* fix(commands): ``cls`` parameter can now be passed like in d.py

* chore: add changelog entry

* Update changelog.d/2881.misc.rst

Co-Authored-By: Toby Harradine <Tobotimus@users.noreply.github.com>

* Rename 2881.misc.rst to 2881.enhance.rst
2019-09-28 17:24:49 -04:00
jack1142
80628a28a7 [Core] Give friendly error when provided instance name doesn't exist. (#2969)
* Update data_manager.py

* Towncrier entry
2019-09-28 17:22:45 -04:00
Michael H
83483abfa5
Reserves command names (#2977)
* Reserves command names

  - Currently, only reserving ``cancel``
  - This should only impact matching command qualified names
  - This also checks aliases
  - This makes cc and alias use the new module constant with info about
  this
  - Module constant is available for use by 3rd party cogs which may
  dynamically create responses.

* Change misleading var name

* style

* Thanks Flame!

* Handles issues with CC
2019-09-28 16:58:40 -04:00
Michael H
e38c08ab12
fix uptime for uptime of less than a second (#3009)
* fix uptime for uptime of less than a second

* changelog

* More conclusive fix
2019-09-28 15:35:26 -04:00
Michael H
c288185a16
Fix a misplaced changelog file (#3019) 2019-09-28 09:59:21 -04:00
Michael H
ee162f6f9e
Fixes an issue with allowed_by_whitelist_blacklist (#3017) 2019-09-27 16:12:29 -04:00
Michael H
25614620db
More privatization, and some error helpers (#2976)
* More privatization, and some error helpers

This makes a lot more things private. Continued from #2967, fixes #2984
Adds public methods for various things.

Below is a brief summary of things available elsewhere, though this
particular set of changes may warrant a detailed section in the release notes.

 - bot.db.locale -> redbot.core.i18n.get_locale
   - Note: This one already existed.
 - bot.db.help -> redbot.core.commands.help.HelpSettings
 - bot db whitelist/blaclist? -> bot.allowed_by_whitelist_blacklist
   - This has also been made a single cannonical function for this
   purpose including check usage
 - bot color? -> bot.get_embed_color/bot.get_embed_colour
 - bot.id.api_tokens? ->

   - bot.get_shared_api_tokens
   - bot.set_shared_api_tokens
   - bot.remove_shared_api_tokens

 -bot.db.prefix -> bot.get_valid_prefixes
   - (Note: This is a wrapper around bot.get_prefix)

 Other changes include
  - removing `bot.counter` as it was never used anywhere
  - Adding properties with helpful error messages for moved and renamed
  things
  - making bot.uptime a property with an error on set
  - adding a migration to the bot config for shared_api_tokens

* Remove overly encompassing message redaction, eval is a risk, dont run in dev if you cant manage it

* address Flame's feedback

* rephrase example

* changelog extras

* You saw nothing
2019-09-26 12:55:05 -04:00
Michael H
af97175839
Fix an issue with clearing permission rules (#3015)
Fixes #3014
2019-09-26 11:41:11 -04:00
Draper
575e55cb0f Fixed crash originated in bank.set_balance (#2997)
* 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>

* Pushed the Fix for new issue introduced by #2926

Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>

* Changelogs

Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>

* Rename changelog to a misc

Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>

* Address Flame's review

Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>

* Correct an outdated reference in the docs

Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>

* Reword docstring for the RuntimeError

Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>
2019-09-22 02:05:27 -04:00
Michael H
ee3be8b633 Extra info (#3008)
* Extra info

* changelog
2019-09-20 16:55:46 +02:00
Flame442
7f22d27d51 Fixes the logic of MessagePredicate.greater and MessagePredicate.less (#3004)
* Fixes the logic of MessagePredicate.greater and MessagePredicate.less

* Create 3004.bugfix.rst
2019-09-18 17:15:24 -04:00
Michael H
4546ca9ba6
Clarify usage of humanize_timedelta (#3000)
- resolves #2986
2019-09-15 19:32:07 -04:00
jack1142
cdb7a02cb8 [Core] Fix infinite typing for commands with cooldown (#2987)
* fix(core): cooldown error can't reinvoke command (infinite typing issue)

* chore(changelog): add towncrier entry
2019-09-07 19:25:02 -04:00
Flame442
0be3b1acd7 Fixes the strings of [p]set usebotcolor (#2974)
* Fixes the help text of `[p]set usebotcolor`

* Create 2974.bugfix.rst
2019-09-02 09:43:56 -04:00
Michael H
6075c5bde0
Rename bot.db as bot._config (#2967)
* 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*
2019-09-01 15:42:28 -04:00
Draper
7959e0c916 [Bank] Allow Bot Owner/Guild Owners to remove invalid users from the bank (#2845)
* 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>
2019-08-30 17:35:25 -04:00
DJtheRedstoner
ef3ac77bd8 Fix issues with embed_requested() (#2966)
* Fix issues with embed_requested()

* Update embed_requested()

Make embed_requested()'s user settings only affect DM's

* Towncrier for #2966
2019-08-30 17:20:34 -04:00
Flame442
efcf91e934 Catch discord.errors.Forbidden when DMing a user the invite message (#2948)
* 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
2019-08-29 21:19:19 -04:00
aikaterna
b8a7a66566 [Core] Inviteset public and perms help cleanup (#2963)
* [Core] Inviteset public and perms help cleanup

* Towncrier entry
2019-08-29 21:18:43 -04:00
Draper
e04eed4a89 [Bank] Allow bank managers to set the maximum allowed balance in the bank (#2926)
* 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>
2019-08-29 21:05:31 -04:00
jack1142
26cc85806e [Utils] Stop using : in backup's filename - Windows doesn't accept it (#2957) 2019-08-28 12:01:02 +10:00
Michael H
2c8152606c [Modlog] Reduce potential for bad API calls (#2945)
- brings a fix over from #2934
2019-08-28 08:45:56 +10:00
Draper
3c1b6ae4cf [Utils] Add humanize_number() function to chat formatting (#2836)
This adds babel as a dependency, and also includes `redbot.core.i18n.get_babel_locale()`
2019-08-28 08:44:52 +10:00
Michael H
bbd30411fd
Fixed small docstring inconsistency (#2924)
* Fixed docs inconsistency

* Added changelog entry

* Changed category from bugfix to misc
2019-08-27 12:40:36 -04:00
Draper
2056f9f8d0 [Bank] Check recipient balance before completing transfer (#2925)
* 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>
2019-08-27 12:40:11 -04:00
Toby Harradine
326c53d6c4
Quick fix for postgres config details prompt (#2951)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-08-27 14:25:05 +10:00
Toby Harradine
d1a46acc9a PostgreSQL driver, tests against DB backends, and general drivers cleanup (#2723)
* 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>
2019-08-26 22:02:26 -04:00
El Laggron
43da727a9f [Utils] Text to file (#2849) 2019-08-26 10:13:21 +10:00
Flame442
dfb4212d43 [Docs] Fix user parameter to predicates being typed as discord.TextChannel (#2914) 2019-08-18 09:05:22 +10:00
Michael H
984a97d958
[Core Commands] remove set owner and set token (#2928)
* remove set-owner and set token

* whoops, wrong number on the changelog

* whoops, git didnt detect the rename cause I didnt add the file
2019-08-13 13:57:16 -04:00
DevilXD
477a17d0b9
Fixed docs inconsistency 2019-08-08 17:06:11 +02:00
Draper
556af32bb5 Stop saving JSON files with indents (#2921)
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>
2019-08-07 10:13:31 +10:00
Toby Harradine
ef8b9b81c3 [ModLog] Optimise get_next_case_number() (#2908)
* [ModLog] Optimise get_next_case_number()

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Address reviews

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add changelog entry

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Delete get_next_case_number

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add modlog.get_latest_case() and fix `[p]reason`

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-08-02 10:49:22 -04:00
DiscordLiz
20091cc10a [ModLog API] Add default casetypes, remove need for a specific auditlog action (#2901)
* 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
2019-07-27 15:37:29 -04:00
Michael H
6280fd9c28
disabled help hideaways (#2892)
* disabled help hideaways

* can_see fix
2019-07-27 02:36:21 -04:00
Toby Harradine
af096bc1cc Config locks (#2654)
* Config locks

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add locks for all_XXX

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Remove a word

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add acquire_lock kwarg for value context manager

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add towncrier entry

Signed-off-by: Toby <tobyharradine@gmail.com>

* Fix issues with `get_custom_lock` and `get_members_lock`

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-07-23 16:50:07 -04:00
DevilXD
7ba50c91a2 Fixed remove_command error when trying to remove a non-existent command (#2889)
* Fixed remove_command error when trying to remove a non-existent command

* Added changelog entry
2019-07-18 05:49:40 -04:00
Toby Harradine
778eadd418
[ModLog] Fix get_case() and get_casetype() (#2877)
This fixes `[p]reason` and `[p]case` with cases that were created after 3.1.3.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-07-15 20:18:21 +10:00
Michael H
49a75b5f19 command translator quick fix (#2870)
* command translator quick fix

* command translator quick fix
2019-07-14 13:55:47 +10:00
Toby Harradine
8676dd3ce3 [i18n] Update translation catalogs (#2867)
* [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>
2019-07-13 23:52:18 -04:00
Toby Harradine
d5c412e3df [Permissions] Fix Requires.ready_event.set() on subcommands (#2868)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-07-13 23:05:07 -04:00
Toby Harradine
f83f378528 [Core] Make Requires.verify() wait until rules are loaded (#2857)
* 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>
2019-07-13 20:47:40 -04:00
Michael H
21a6384ebf [Modlog] Fix get_case for missing cases (#2858)
Due to the modlog redesign, the detection for a missing case changed. This fixes `get_case` for this.

This resolves #2844.
2019-07-14 10:47:16 +10:00
Toby Harradine
03e0683dd7 [ModLog] Actually prevent duplicate kwarg error
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-07-13 14:39:50 +10:00
Michael H
ac2813012a
[Core] Cog load fixes (#2854)
* split out some fixes from red#2853

* address feedback

* feedback
2019-07-12 22:11:06 -04:00
Toby Harradine
e34eca557b [ModLog] Prevent duplicate kwarg error (#2848)
* [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>
2019-07-12 20:17:00 -04:00
DevilXD
776c75ba86 Fixed [p] not being replaced in code blocks (#2846) 2019-07-09 03:22:52 -04:00
Toby Harradine
f2039300c2 [Mongo] Use escaped identifiers to extract inner value (#2832)
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>
2019-07-05 18:02:18 -04:00
Draper
a89a156f8e [Context] Adds react_quietly method to context (#2834)
* [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
2019-07-03 15:26:22 -04:00