WIP: Aurora V3 #48

Draft
cswimr wants to merge 21 commits from aurora/v3 into main
Showing only changes of commit 850ddf15a6 - Show all commits

View file

@ -1,5 +1,5 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Any, Dict, Tuple from typing import TYPE_CHECKING, Any, Dict, Tuple
from class_registry import ClassRegistry from class_registry import ClassRegistry
from class_registry.base import AutoRegister from class_registry.base import AutoRegister
@ -7,10 +7,13 @@ from discord import Interaction, Member, User
from discord.abc import Messageable from discord.abc import Messageable
from redbot.core import commands from redbot.core import commands
if TYPE_CHECKING:
from .moderation import Moderation
type_registry: Dict["str", "Type"] = ClassRegistry(attr_name="key", unique=True) type_registry: Dict["str", "Type"] = ClassRegistry(attr_name="key", unique=True)
class Type(AutoRegister(type_registry), ABC): class Type(AutoRegister(registry=type_registry), ABC):
"""This is a base class for moderation types. """This is a base class for moderation types.
Attributes: Attributes:
@ -65,7 +68,7 @@ class Type(AutoRegister(type_registry), ABC):
raise NotImplementedError raise NotImplementedError
@classmethod @classmethod
async def resolve_handler(cls, moderation, reason: str) -> Tuple[bool, str]: # pylint: disable=unused-argument async def resolve_handler(cls, moderation: "Moderation", reason: str) -> Tuple[bool, str]: # pylint: disable=unused-argument
"""This method should be overridden by any resolvable child classes, but should retain the same keyword arguments. """This method should be overridden by any resolvable child classes, but should retain the same keyword arguments.
If your moderation type should not be resolvable, do not override this. If your moderation type should not be resolvable, do not override this.
@ -76,7 +79,7 @@ class Type(AutoRegister(type_registry), ABC):
raise NotImplementedError raise NotImplementedError
@classmethod @classmethod
async def expiry_handler(cls, moderation) -> int: # pylint: disable=unused-argument async def expiry_handler(cls, moderation: "Moderation") -> int: # pylint: disable=unused-argument
"""This method should be overridden by any expirable child classes, but should retain the same keyword arguments and return an integer. """This method should be overridden by any expirable child classes, but should retain the same keyword arguments and return an integer.
If your moderation type should not expire, do not override this, but also do not set an `end_timestamp` when you log your moderation. If your moderation type should not expire, do not override this, but also do not set an `end_timestamp` when you log your moderation.
@ -86,7 +89,7 @@ class Type(AutoRegister(type_registry), ABC):
raise NotImplementedError raise NotImplementedError
@classmethod @classmethod
async def duration_edit_handler(cls, interaction: Interaction, old_moderation, new_moderation) -> bool: # pylint: disable=unused-argument async def duration_edit_handler(cls, interaction: Interaction, old_moderation: "Moderation", new_moderation: "Moderation") -> bool: # pylint: disable=unused-argument
"""This method should be overridden by any child classes with editable durations, but should retain the same keyword arguments and should return True if the duration was successfully modified, or False if it was not. """This method should be overridden by any child classes with editable durations, but should retain the same keyword arguments and should return True if the duration was successfully modified, or False if it was not.
If your moderation type's duration should not be editable, do not override this. If your moderation type's duration should not be editable, do not override this.