mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 02:16:09 -05:00
Warn when new slotmin/slotmax value will cause slots to not work (#4583)
* Properly handle slotmin/slotmax rules * Use a variable to reduce config calls. No reason to process differently half way through a command anyways. * Update redbot/cogs/economy/economy.py * Add positive int converter for slotmin/slotmax * Option to allow bad mins and maxes. * Update economy.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
22
redbot/cogs/economy/converters.py
Normal file
22
redbot/cogs/economy/converters.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from typing import NewType, TYPE_CHECKING
|
||||
|
||||
from redbot.core.commands import BadArgument
|
||||
from redbot.core.i18n import Translator
|
||||
from redbot.core.utils.chat_formatting import inline
|
||||
|
||||
_ = Translator("Economy", __file__)
|
||||
|
||||
# Duplicate of redbot.cogs.cleanup.converters.PositiveInt
|
||||
PositiveInt = NewType("PositiveInt", int)
|
||||
if TYPE_CHECKING:
|
||||
positive_int = PositiveInt
|
||||
else:
|
||||
|
||||
def positive_int(arg: str) -> int:
|
||||
try:
|
||||
ret = int(arg)
|
||||
except ValueError:
|
||||
raise BadArgument(_("{arg} is not an integer.").format(arg=inline(arg)))
|
||||
if ret <= 0:
|
||||
raise BadArgument(_("{arg} is not a positive integer.").format(arg=inline(arg)))
|
||||
return ret
|
||||
Reference in New Issue
Block a user