mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Move private things in modlog and redbot.core.errors (#6020)
This commit is contained in:
parent
dcdef9d798
commit
8b1daf1ad0
@ -18,7 +18,7 @@ except ModuleNotFoundError:
|
|||||||
pymongo = None
|
pymongo = None
|
||||||
|
|
||||||
from .. import errors
|
from .. import errors
|
||||||
from .base import BaseDriver, IdentifierData
|
from .base import BaseDriver, IdentifierData, MissingExtraRequirements
|
||||||
|
|
||||||
__all__ = ["MongoDriver"]
|
__all__ = ["MongoDriver"]
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ class MongoDriver(BaseDriver):
|
|||||||
@classmethod
|
@classmethod
|
||||||
async def initialize(cls, **storage_details) -> None:
|
async def initialize(cls, **storage_details) -> None:
|
||||||
if motor is None:
|
if motor is None:
|
||||||
raise errors.MissingExtraRequirements(
|
raise MissingExtraRequirements(
|
||||||
"Red must be installed with the [mongo] extra to use the MongoDB driver"
|
"Red must be installed with the [mongo] extra to use the MongoDB driver"
|
||||||
)
|
)
|
||||||
uri = storage_details.get("URI", "mongodb")
|
uri = storage_details.get("URI", "mongodb")
|
||||||
|
|||||||
@ -6,7 +6,11 @@ import rich.progress
|
|||||||
|
|
||||||
from redbot.core.utils._internal_utils import RichIndefiniteBarColumn
|
from redbot.core.utils._internal_utils import RichIndefiniteBarColumn
|
||||||
|
|
||||||
__all__ = ["BaseDriver", "IdentifierData", "ConfigCategory"]
|
__all__ = ("BaseDriver", "IdentifierData", "ConfigCategory", "MissingExtraRequirements")
|
||||||
|
|
||||||
|
|
||||||
|
class MissingExtraRequirements(Exception):
|
||||||
|
"""Raised when an extra requirement is missing but required."""
|
||||||
|
|
||||||
|
|
||||||
class ConfigCategory(str, enum.Enum):
|
class ConfigCategory(str, enum.Enum):
|
||||||
|
|||||||
@ -11,7 +11,7 @@ except ModuleNotFoundError:
|
|||||||
asyncpg = None
|
asyncpg = None
|
||||||
|
|
||||||
from ... import data_manager, errors
|
from ... import data_manager, errors
|
||||||
from ..base import BaseDriver, IdentifierData, ConfigCategory
|
from ..base import BaseDriver, IdentifierData, ConfigCategory, MissingExtraRequirements
|
||||||
from ..log import log
|
from ..log import log
|
||||||
|
|
||||||
__all__ = ["PostgresDriver"]
|
__all__ = ["PostgresDriver"]
|
||||||
@ -41,7 +41,7 @@ class PostgresDriver(BaseDriver):
|
|||||||
@classmethod
|
@classmethod
|
||||||
async def initialize(cls, **storage_details) -> None:
|
async def initialize(cls, **storage_details) -> None:
|
||||||
if asyncpg is None:
|
if asyncpg is None:
|
||||||
raise errors.MissingExtraRequirements(
|
raise MissingExtraRequirements(
|
||||||
"Red must be installed with the [postgres] extra to use the PostgreSQL driver"
|
"Red must be installed with the [postgres] extra to use the PostgreSQL driver"
|
||||||
)
|
)
|
||||||
cls._pool = await asyncpg.create_pool(**storage_details)
|
cls._pool = await asyncpg.create_pool(**storage_details)
|
||||||
|
|||||||
@ -2757,7 +2757,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
@modlogset.command(hidden=True, name="fixcasetypes")
|
@modlogset.command(hidden=True, name="fixcasetypes")
|
||||||
async def modlogset_fixcasetypes(self, ctx: commands.Context):
|
async def modlogset_fixcasetypes(self, ctx: commands.Context):
|
||||||
"""Command to fix misbehaving casetypes."""
|
"""Command to fix misbehaving casetypes."""
|
||||||
await modlog.handle_auditype_key()
|
await modlog._handle_audit_type_key()
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
|
|
||||||
@modlogset.command(aliases=["channel"], name="modlog")
|
@modlogset.command(aliases=["channel"], name="modlog")
|
||||||
|
|||||||
@ -67,10 +67,6 @@ class BankPruneError(BankError):
|
|||||||
"""Raised when trying to prune a local bank and no server is specified."""
|
"""Raised when trying to prune a local bank and no server is specified."""
|
||||||
|
|
||||||
|
|
||||||
class MissingExtraRequirements(RedError):
|
|
||||||
"""Raised when an extra requirement is missing but required."""
|
|
||||||
|
|
||||||
|
|
||||||
class ConfigError(RedError):
|
class ConfigError(RedError):
|
||||||
"""Error in a Config operation."""
|
"""Error in a Config operation."""
|
||||||
|
|
||||||
|
|||||||
@ -120,7 +120,7 @@ async def _init(bot: Red):
|
|||||||
bot.add_listener(on_audit_log_entry_create)
|
bot.add_listener(on_audit_log_entry_create)
|
||||||
|
|
||||||
|
|
||||||
async def handle_auditype_key():
|
async def _handle_audit_type_key():
|
||||||
all_casetypes = {
|
all_casetypes = {
|
||||||
casetype_name: {
|
casetype_name: {
|
||||||
inner_key: inner_value
|
inner_key: inner_value
|
||||||
@ -162,7 +162,7 @@ async def _migrate_config(from_version: int, to_version: int):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if from_version < 3 <= to_version:
|
if from_version < 3 <= to_version:
|
||||||
await handle_auditype_key()
|
await _handle_audit_type_key()
|
||||||
await _config.schema_version.set(3)
|
await _config.schema_version.set(3)
|
||||||
|
|
||||||
if from_version < 4 <= to_version:
|
if from_version < 4 <= to_version:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user