fix(aurora): fixed an AttributeError
This commit is contained in:
parent
aeec616be5
commit
f2a88cbf94
2 changed files with 28 additions and 17 deletions
|
@ -21,9 +21,8 @@ def get_icon(bot: Red) -> File:
|
||||||
|
|
||||||
@type_registry.register(key="ban")
|
@type_registry.register(key="ban")
|
||||||
class Ban(Type):
|
class Ban(Type):
|
||||||
def __init__(self) -> None:
|
moderation_type="ban"
|
||||||
self.type="ban"
|
verb="banned"
|
||||||
self.verb="banned"
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def handler(cls, ctx: commands.Context, target: Member | User, silent: bool, reason: str = None, delete_messages: app_commands.Choice | None = None) -> 'Ban':
|
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),
|
await bot.get_embed_color(ctx.channel),
|
||||||
ctx.guild,
|
ctx.guild,
|
||||||
reason,
|
reason,
|
||||||
cls.type,
|
cls(),
|
||||||
ctx.author,
|
ctx.author,
|
||||||
None,
|
None,
|
||||||
response_message
|
response_message
|
||||||
|
@ -63,7 +62,7 @@ class Ban(Type):
|
||||||
bot,
|
bot,
|
||||||
ctx.guild.id,
|
ctx.guild.id,
|
||||||
ctx.author.id,
|
ctx.author.id,
|
||||||
cls.type,
|
cls.moderation_type,
|
||||||
'USER',
|
'USER',
|
||||||
target.id,
|
target.id,
|
||||||
None,
|
None,
|
||||||
|
@ -76,7 +75,7 @@ class Ban(Type):
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
@classmethod
|
@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:
|
try:
|
||||||
await guild.fetch_ban(user=target)
|
await guild.fetch_ban(user=target)
|
||||||
except NotFound:
|
except NotFound:
|
||||||
|
@ -100,10 +99,8 @@ class Ban(Type):
|
||||||
|
|
||||||
@type_registry.register(key="tempban")
|
@type_registry.register(key="tempban")
|
||||||
class Tempban(Ban):
|
class Tempban(Ban):
|
||||||
def __init__(self) -> None:
|
moderation_type="tempban"
|
||||||
super().__init__()
|
verb="tempbanned"
|
||||||
self.type="tempban"
|
|
||||||
self.verb="tempbanned"
|
|
||||||
|
|
||||||
@classmethod
|
@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':
|
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),
|
await bot.get_embed_color(ctx.channel),
|
||||||
ctx.guild,
|
ctx.guild,
|
||||||
reason,
|
reason,
|
||||||
cls.type,
|
cls(),
|
||||||
ctx.author,
|
ctx.author,
|
||||||
parsed_time,
|
parsed_time,
|
||||||
response_message
|
response_message
|
||||||
|
@ -151,7 +148,7 @@ class Tempban(Ban):
|
||||||
bot,
|
bot,
|
||||||
ctx.guild.id,
|
ctx.guild.id,
|
||||||
ctx.author.id,
|
ctx.author.id,
|
||||||
cls.type,
|
cls.moderation_type,
|
||||||
'USER',
|
'USER',
|
||||||
target.id,
|
target.id,
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -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 import commands
|
||||||
|
from redbot.core.bot import Red
|
||||||
|
|
||||||
|
|
||||||
class Type(object):
|
class Type(object):
|
||||||
def __init__(self) -> None:
|
moderation_type = None
|
||||||
self.type = None
|
verb = None
|
||||||
self.verb = None
|
embed_desc = "been"
|
||||||
self.embed_desc = "been"
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.type
|
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
|
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."""
|
"""This method should be overridden by any child classes, but should retain the same starting keyword arguments."""
|
||||||
raise NotImplementedError
|
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
|
||||||
|
|
Loading…
Reference in a new issue