mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 09:52:30 -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:
@@ -4,10 +4,10 @@ import pkgutil
|
||||
from importlib import import_module, invalidate_caches
|
||||
from importlib.machinery import ModuleSpec
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Union, List, Optional
|
||||
from typing import Union, List, Optional
|
||||
|
||||
import redbot.cogs
|
||||
from redbot.core.commands import BadArgument
|
||||
from redbot.core.commands import positive_int
|
||||
from redbot.core.utils import deduplicate_iterables
|
||||
import discord
|
||||
|
||||
@@ -21,21 +21,6 @@ from .utils.chat_formatting import box, pagify, humanize_list, inline
|
||||
__all__ = ["CogManager"]
|
||||
|
||||
|
||||
# Duplicate of redbot.cogs.cleanup.converters.positive_int
|
||||
if TYPE_CHECKING:
|
||||
positive_int = int
|
||||
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
|
||||
|
||||
|
||||
class NoSuchCog(ImportError):
|
||||
"""Thrown when a cog is missing.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user