Compare commits

..

No commits in common. "850ddf15a6bc222a62778ffbcdbb6f9240131b37" and "e79dfd6b9462dfc4d96b31125dd184c810f065a7" have entirely different histories.

2 changed files with 5 additions and 10 deletions

View file

@ -1,2 +0,0 @@
from .moderation_types import * # noqa: F403
# This just imports all the built-in moderation types so they can be registered, as they aren't imported anywhere else.

View file

@ -1,5 +1,5 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Dict, Tuple from typing import 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,13 +7,10 @@ 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(registry=type_registry), ABC): class Type(AutoRegister(type_registry), ABC):
"""This is a base class for moderation types. """This is a base class for moderation types.
Attributes: Attributes:
@ -68,7 +65,7 @@ class Type(AutoRegister(registry=type_registry), ABC):
raise NotImplementedError raise NotImplementedError
@classmethod @classmethod
async def resolve_handler(cls, moderation: "Moderation", reason: str) -> Tuple[bool, str]: # pylint: disable=unused-argument async def resolve_handler(cls, 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.
@ -79,7 +76,7 @@ class Type(AutoRegister(registry=type_registry), ABC):
raise NotImplementedError raise NotImplementedError
@classmethod @classmethod
async def expiry_handler(cls, moderation: "Moderation") -> int: # pylint: disable=unused-argument async def expiry_handler(cls, 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.
@ -89,7 +86,7 @@ class Type(AutoRegister(registry=type_registry), ABC):
raise NotImplementedError raise NotImplementedError
@classmethod @classmethod
async def duration_edit_handler(cls, interaction: Interaction, old_moderation: "Moderation", new_moderation: "Moderation") -> bool: # pylint: disable=unused-argument async def duration_edit_handler(cls, interaction: Interaction, old_moderation, new_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.