Move modlogset/bankset commands to core (#4486)

* Move bankset and modlogset to core commands

* Move prune over too

* Finish moving prune

* Move [p]economyset registeramount to [p]bankset registeramount

* style fix

* Fix circular import issue with another breaking change

* Apparently I missed a conflict and git still let me commit...

* Really git?

* Rename RawUserIds -> RawUserIdConverter, improve documentation

* Improve documentation of `is_owner_if_bank_global()`

* MENTION_REGEX -> USER_MENTION_REGEX

* Add 'bank.' prefix

* Fix command examples in docstrings

* Missing docstring change from `bankset prune`

* Missing changes for commands in modlogset

* Update docs

* Remove duplicated info in `economyset showsettings`

* Fix toctree in index.rst

* Add command group prefixes to names of functions for bankset/modlogset

* Remaining string updates due to command name changes

* Ensure that the bank folder is actually gone

Co-authored-by: palmtree5 <palmtree5+3577255@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
palmtree5
2021-11-25 00:06:30 -09:00
committed by GitHub
parent fc560db72d
commit 6acdcdeae9
58 changed files with 830 additions and 5046 deletions

View File

@@ -43,6 +43,7 @@ __all__ = [
"cost",
"AbortPurchase",
"bank_prune",
"is_owner_if_bank_global",
]
_MAX_BALANCE = 2 ** 63 - 1
@@ -147,6 +148,44 @@ async def _process_data_deletion(
await _config.member_from_ids(guild_id, user_id).clear()
def is_owner_if_bank_global():
"""
Restrict the command to the bot owner if the bank is global,
otherwise ensure it's used in guild (WITHOUT checking any user permissions).
When used on the command, this should be combined
with permissions check like `guildowner_or_permissions()`.
This is a `command check <discord.ext.commands.check>`.
Example
-------
.. code-block:: python
@bank.is_owner_if_bank_global()
@checks.guildowner()
@commands.group()
async def bankset(self, ctx: commands.Context):
\"""Base command for bank settings.\"""
If the bank is global, the ``[p]bankset`` command can only be used by
the bot owners in both guilds and DMs.
If the bank is local, the command can only be used in guilds by guild and bot owners.
"""
async def pred(ctx: commands.Context):
author = ctx.author
if not await is_global():
if not ctx.guild:
return False
return True
else:
return await ctx.bot.is_owner(author)
return commands.check(pred)
class Account:
"""A single account.