New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bank] Allow Bot Owner/Guild Owners to remove invalid users from the bank #2845
[Bank] Allow Bot Owner/Guild Owners to remove invalid users from the bank #2845
Conversation
I'm not sure this is a great idea to add prior to proper bulk interfaces in config. If we do decide to add this as is, it will at minimum need a Have not tested this, though the logic itself should be fine from a brief glance. |
…plemented 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
I still think this needs some more discussion, however I have reviewed the code as-is so it can be improved.
Additional comments that don't apply to a particular line:
-All of the places you use member=member
, you might want to use member=member.display_name
instead so that it will use nicknames.
-It would be nice if this supported global banks and had an extra check that the invoker is a bot owner when the bank is global.
# Conflicts: # redbot/cogs/economy/economy.py
…ng the command agaisn't invalid formats
Removed aliases that used old naming scheme
I agree but how would this work? Since Global bank means the balance works across servers. Or do you mean that the |
If the bank is global, accounts will be tied to Users (rather than Members). Bot owners should be able to delete a user's account when the bank is global and possibly clear all users that no longer share a guild with the bot. |
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
Global support has been added, also reworked perms and names: [p]bank prune local : Can be run by Guild owners only |
…4:Field list ends without a blank line
After deleting my bank account with [p]bank prune user Flame yes
, [p]bank balance
returns this error (I'm not cropping it because I don't know how much is useful and I'm too tired to check):
Exception in command 'bank balance'
Traceback (most recent call last):
File "c:\Users\Flame\Desktop\Random\TestingRedbot\reddev\VENV\lib\site-packages\discord\ext\commands\core.py", line 63, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\Flame\Desktop\Random\TestingRedbot\reddev\VENV\lib\site-packages\redbot\cogs\economy\economy.py", line 157, in balance
bal = await bank.get_balance(user)
File "c:\Users\Flame\Desktop\Random\TestingRedbot\reddev\VENV\lib\site-packages\redbot\core\bank.py", line 139, in get_balance
acc = await get_account(member)
File "c:\Users\Flame\Desktop\Random\TestingRedbot\reddev\VENV\lib\site-packages\redbot\core\bank.py", line 492, in get_account
all_accounts = await _conf.all_users()
File "c:\Users\Flame\Desktop\Random\TestingRedbot\reddev\VENV\lib\site-packages\redbot\core\config.py", line 1057, in all_users
return await self._all_from_scope(self.USER)
File "c:\Users\Flame\Desktop\Random\TestingRedbot\reddev\VENV\lib\site-packages\redbot\core\config.py", line 987, in _all_from_scope
ret[int(k)] = data
ValueError: invalid literal for int() with base 10: 'name'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\Users\Flame\Desktop\Random\TestingRedbot\reddev\VENV\lib\site-packages\discord\ext\commands\bot.py", line 860, in invoke
await ctx.command.invoke(ctx)
File "c:\Users\Flame\Desktop\Random\TestingRedbot\reddev\VENV\lib\site-packages\redbot\core\commands\commands.py", line 570, in invoke
await super().invoke(ctx)
File "c:\Users\Flame\Desktop\Random\TestingRedbot\reddev\VENV\lib\site-packages\discord\ext\commands\core.py", line 1127, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "c:\Users\Flame\Desktop\Random\TestingRedbot\reddev\VENV\lib\site-packages\discord\ext\commands\core.py", line 698, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "c:\Users\Flame\Desktop\Random\TestingRedbot\reddev\VENV\lib\site-packages\discord\ext\commands\core.py", line 72, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: invalid literal for int() with base 10: 'name'
This same error appears for other commands that interact with the bank, such as [p]payday
. I can't really test this effectively with this happening.
Fixed [p]bank prune user, When run via DM it will now return an error message to the user (Thanks jack1142)
All of the things I wanted to see fixed have been fixed. Thanks for working with me.
Per request in discord until a command is added for this.
…ordBot into removedead Signed-off-by: Draper <guyreis96@gmail.com> # Conflicts: # redbot/cogs/economy/economy.py # redbot/core/bank.py # redbot/core/config.py
Signed-off-by: Draper <guyreis96@gmail.com>
Signed-off-by: guyre <27962761+drapersniper@users.noreply.github.com>
Type
Description of the changes
Sinbad Please dont kill me for using a protected member of
Config
Add 2 new commands
removedead
which clears all users who are in the database but are no longer in guildand
memberdelete
which complete delete a users bank accountBoth can only be run by guild owners