mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-09 10:52:31 -05:00
Add public positive_int and finite_float converters (#5969)
Co-authored-by: Kreusada <67752638+Kreusada@users.noreply.github.com>
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
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
|
||||
@@ -5,18 +5,17 @@ from collections import defaultdict, deque, namedtuple
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from enum import Enum
|
||||
from math import ceil
|
||||
from typing import cast, Iterable, Union, Literal
|
||||
from typing import cast, Iterable, Literal
|
||||
|
||||
import discord
|
||||
|
||||
from redbot.core import Config, bank, commands, errors
|
||||
from redbot.core.commands.converter import TimedeltaConverter
|
||||
from redbot.core.commands.converter import TimedeltaConverter, positive_int
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.i18n import Translator, cog_i18n
|
||||
from redbot.core.utils import AsyncIter
|
||||
from redbot.core.utils.chat_formatting import box, humanize_number
|
||||
from redbot.core.utils.menus import close_menu, menu
|
||||
from .converters import positive_int
|
||||
from redbot.core.utils.menus import menu
|
||||
|
||||
T_ = Translator("Economy", __file__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user