fix(aurora): fixed an AttributeError
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Failing after 26s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 40s

This commit is contained in:
Seaswimmer 2024-07-06 11:46:13 -04:00
parent aeec616be5
commit f2a88cbf94
Signed by: cswimr
GPG key ID: 3813315477F26F82
2 changed files with 28 additions and 17 deletions

View file

@ -21,9 +21,8 @@ def get_icon(bot: Red) -> File:
@type_registry.register(key="ban")
class Ban(Type):
def __init__(self) -> None:
self.type="ban"
self.verb="banned"
moderation_type="ban"
verb="banned"
@classmethod
async def handler(cls, ctx: commands.Context, target: Member | User, silent: bool, reason: str = None, delete_messages: app_commands.Choice | None = None) -> 'Ban':
@ -49,7 +48,7 @@ class Ban(Type):
await bot.get_embed_color(ctx.channel),
ctx.guild,
reason,
cls.type,
cls(),
ctx.author,
None,
response_message
@ -63,7 +62,7 @@ class Ban(Type):
bot,
ctx.guild.id,
ctx.author.id,
cls.type,
cls.moderation_type,
'USER',
target.id,
None,
@ -76,7 +75,7 @@ class Ban(Type):
return cls
@classmethod
async def resolve_handler(cls, bot: Red, guild: Guild, target: Member, reason: str):
async def resolve_handler(cls, bot: Red, guild: Guild, target: Member | User, reason: str | None = None) -> None:
try:
await guild.fetch_ban(user=target)
except NotFound:
@ -100,10 +99,8 @@ class Ban(Type):
@type_registry.register(key="tempban")
class Tempban(Ban):
def __init__(self) -> None:
super().__init__()
self.type="tempban"
self.verb="tempbanned"
moderation_type="tempban"
verb="tempbanned"
@classmethod
async def handler(cls, ctx: commands.Context, target: Member | User, silent: bool, duration: str, reason: str = None, delete_messages: app_commands.Choice | None = None) -> 'Ban':
@ -137,7 +134,7 @@ class Tempban(Ban):
await bot.get_embed_color(ctx.channel),
ctx.guild,
reason,
cls.type,
cls(),
ctx.author,
parsed_time,
response_message
@ -151,7 +148,7 @@ class Tempban(Ban):
bot,
ctx.guild.id,
ctx.author.id,
cls.type,
cls.moderation_type,
'USER',
target.id,
None,

View file

@ -1,13 +1,15 @@
from discord import Member, User
from typing import Any
from discord import Guild, Member, User
from redbot.core import commands
from redbot.core.bot import Red
class Type(object):
def __init__(self) -> None:
self.type = None
self.verb = None
self.embed_desc = "been"
moderation_type = None
verb = None
embed_desc = "been"
def __str__(self) -> str:
return self.type
@ -16,3 +18,15 @@ class Type(object):
async def handler(cls, ctx: commands.Context, target: Member | User, silent: bool, **kwargs) -> 'Type': # pylint: disable=unused-argument
"""This method should be overridden by any child classes, but should retain the same starting keyword arguments."""
raise NotImplementedError
@classmethod
async def resolve_handler(cls, bot: Red, guild: Guild, target: Member | User, reason: str | None = None) -> Any: # pylint: disable=unused-argument
"""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."""
raise NotImplementedError
@classmethod
async def expiry_handler(cls, bot: Red, guild: Guild, target: Member | User) -> Any: # pylint: disable=unused-argument
"""This method should be overridden by any expirable child classes, but should retain the same keyword arguments.
If your moderation type should not expire, do not override this."""
raise NotImplementedError