23 Commits

Author SHA1 Message Date
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
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
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
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
Michael H
0eb22c84ff [Bank API] Add cost decorator (#2761) 2019-07-03 10:07:19 +10:00
Toby Harradine
b1066ad58f
Guard module-level creation of Config objects (#2449)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-02-14 15:36:48 +11:00
Toby Harradine
d2d26835c3
[Economy] Detect max balance and prevent OverflowError (#2211)
Resolves #2091.

This doesn't fix every OverflowError with MongoDB; but at least the seemingly easiest one to achieve with core cogs.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-16 09:30:53 +11:00
Toby Harradine
fa692ccc0b [i18n] Pass over economy, filter, general, image, mod
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-06 09:00:31 +10:00
Toby Harradine
dbed24aaca
[Config] Group.__call__() has same behaviour as Group.all() (#2018)
* Make calling groups useful

This makes config.Group.__call__ effectively an alias for Group.all(),
with the added bonus of becoming a context manager.

get_raw has been updated as well to reflect the new behaviour of
__call__.

* Fix unintended side-effects of new behaviour

* Add tests

* Add test for get_raw mixing in defaults

* Another cleanup for relying on old behaviour internally

* Fix bank relying on old behaviour

* Reformat
2018-08-26 23:30:36 +10:00
Toby Harradine
652ceba845
[Bank] Raise TypeError when passing a non-int transaction amount (#1976)
* Raise TypeError when passing a non-int bank amount

* Add a test

* Add some full stops
2018-08-09 22:13:31 +10:00
Redjumpman
f6823ea3d1 Update bank.py (#1937) 2018-07-25 02:57:25 +02:00
Eslyium
60a72b2ba4 [V3] Cleanup quotes in cogs (#1782)
* 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
2018-06-07 00:42:59 -04:00
Michael H
b88b5a2601 [V3] Update code standards (black code format pass) (#1650)
* ran black: code formatter against `redbot/` with `-l 99`

* badge
2018-05-14 15:33:24 -04:00
Michael H
f8e7497695 [V3] Remove old usage of type tuples with config (#1518) 2018-04-16 21:41:13 -04:00
palmtree5
4e2b83c052 [V3 Docs] Add and update existing features (#1451)
* [V3 Docs] bump version

* Remove removed functions from __all__

* Update docstring format

* Update copyright year

* Add embed utils docs

* Document bot class

* Document RPC

* Update toctree
2018-03-24 17:27:04 -04:00
palmtree5
f83e3cc3e7 [V3 Economy] Expand payday output (#1386)
* [V3 Economy] implement suggestions from #1371

* Fix a typo

* Add functions for getting leaderboard and leaderboard position

* Use the new functions to get leaderboard position and leaderboard (overrides https://github.com/Cog-Creators/Red-DiscordBot/pull/1435)

* Actually implement showing only guild members on leaderboard when bank is global

* get_leaderboard_position needs to be awaited

* For global bank, pass None for guild to get_leaderboard when trying to find position

* Remove some unneeded code

* Wrong index...

* Combine 3 messages into 1

* Fix guild leaderboard while bank is global

* add missing parentheses

* Modify the leaderboard formatting

* More work on leaderboard formatting

* no subtraction
2018-03-20 18:22:10 -04:00
Redjumpman
5bd7a23864 [V3 Bank] Fix can_spend and withdraw_credits (#1234)
* Fixed equality operator

can_spend function should be using a >= instead > so that you can spend all of your currency.

* Update bank.py

Fix for withdraw using the wrong equality operator.

* Revert withdraw_credits

Reverted withdraw_credits back to original operator.
2018-01-11 20:26:34 +01:00
Tobotimus
1b6065bb46 [V3 Economy] Update from config changes (#1084) 2017-11-19 18:01:09 -05:00
Will
fed115996c Fix missing awaits (#1055) 2017-10-24 18:53:10 -08:00
Will
5d48e6f3b1 [V3 Config] Add MongoDB driver (#972)
* Basic Mongo Driver

* Update docstrings

* WIP motor support

* Use motor

* Update docs, add selective importer

* Make use of selective importer

* Fix docs

* Fix config storage location for JSON

* Add delimiters in the drivers doc section

* Make async things async

* Add basic config information for mongo driver

* get info from basic setup into config

* IT WORKS

* Add dependency for RJM's PR.
2017-10-20 19:12:45 -04:00
Tobotimus
815678584f [V3 Config] Redesign "all_from_XXX" and "clear_all" methods (#1033)
* Added alternative to all_from_kind

* Returned dicts include default values

Also added docstrings

Also removed all_globals since it's kind of redundant and it wasn't working out for me

* Refactored clear_all

* Tests

* Tests again..

* Make all new methods coroutines
2017-10-19 23:22:58 -04:00
Tobotimus
c80684a129 [V3] NumPy Docstrings (#1032)
* ALL THE DOCSTRINGS

* Remove imports in drivers package

* Fixed build warnings
2017-10-17 22:01:59 -04:00
Will
d69fd63da7 [V3 Everything] Package bot and write setup scripts (#964)
Ya'll are gonna hate me.

* Initial modifications

* Add initial setup.py

* working setup py help

* Modify setup file to package stuff

* Move a bunch of shit and fix imports

* Fix or skip tests

* Must add init files for find_packages to work

* Move main to scripts folder and rename

* Add shebangs

* Copy over translation files

* WORKING PIP INSTALL

* add dependency information

* Hardcoded version for now, will need to figure out a better way to do this

* OKAY ITS FINALLY FUCKING WORKING

* Add this guy

* Fix stuff

* Change readme to rst

* Remove double sentry opt in

* Oopsie

* Fix this thing

* Aaaand fix test

* Aaaand fix test

* Fix core cog importing and default cog install path

* Adjust readme

* change instance name from optional to required

* Ayyy let's do more dependency injection
2017-09-08 23:14:32 -04:00