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

@@ -34,6 +34,7 @@ if TYPE_CHECKING:
from .context import Context
__all__ = [
"RawUserIdConverter",
"DictConverter",
"UserInputOptional",
"NoParseOptional",
@@ -51,6 +52,7 @@ __all__ = [
_ = Translator("commands.converter", __file__)
ID_REGEX = re.compile(r"([0-9]{15,20})")
USER_MENTION_REGEX = re.compile(r"<@!?([0-9]{15,21})>$")
# Taken with permission from
@@ -204,6 +206,32 @@ def parse_relativedelta(
return None
class RawUserIdConverter(dpy_commands.Converter):
"""
Converts ID or user mention to an `int`.
Useful for commands like ``[p]ban`` or ``[p]unban`` where the bot is not necessarily
going to share any servers with the user that a moderator wants to ban/unban.
This converter doesn't check if the ID/mention points to an actual user
but it won't match IDs and mentions that couldn't possibly be valid.
For example, the converter will not match on "123" because the number doesn't have
enough digits to be valid ID but, it will match on "12345678901234567" even though
there is no user with such ID.
"""
async def convert(self, ctx: "Context", argument: str) -> int:
# This is for the hackban and unban commands, where we receive IDs that
# are most likely not in the guild.
# Mentions are supported, but most likely won't ever be in cache.
if match := ID_REGEX.match(argument) or USER_MENTION_REGEX.match(argument):
return int(match.group(1))
raise BadArgument(_("'{input}' doesn't look like a valid user ID.").format(input=argument))
# Below this line are a lot of lies for mypy about things that *end up* correct when
# These are used for command conversion purposes. Please refer to the portion
# which is *not* for type checking for the actual implementation