WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
Showing only changes of commit 6edda87baa - Show all commits

View file

@ -30,7 +30,6 @@ class Note(Type):
key="note" key="note"
string="note" string="note"
verb="noted" verb="noted"
embed_desc="received a "
def void(self) -> None: def void(self) -> None:
return None return None
@ -284,6 +283,39 @@ class AddRole(Type):
) )
return 0 return 0
@classmethod
async def resolve_handler(cls, moderation: Moderation, reason: str) -> Tuple[bool, str]:
try:
target = await moderation.guild.fetch_member(moderation.target_id)
await target.remove_roles(
Object(moderation.role_id), reason=reason
)
if await config.guild(moderation.guild).dm_users() is True:
try:
embed = await resolve_factory(
moderation=moderation,
reason=reason
)
await target.send(embed=embed, file=get_icon(bot=moderation.bot))
except HTTPException:
pass
logger.trace(
"Removed role %s from %s (%s)",
moderation.role_id,
target.name,
target.id,
)
return True, ""
except (NotFound, Forbidden, HTTPException) as e:
logger.error(
"Failed to remove role %s from user %s (%s)\n%s",
moderation.role_id,
target.name,
target.id,
e,
)
return False, "Failed to remove role from user."
class RemoveRole(Type): class RemoveRole(Type):
key="removerole" key="removerole"
string="removerole" string="removerole"
@ -294,7 +326,7 @@ class RemoveRole(Type):
return None return None
@classmethod @classmethod
async def handler(cls, ctx: commands.Context, target: Member, role: Role, silent: bool, duration: str = None, reason: str = None): async def handler(cls, ctx: commands.Context, target: Member, role: Role, silent: bool, duration: str | None = None, reason: str = None):
addrole_whitelist = await config.guild(ctx.guild).addrole_whitelist() addrole_whitelist = await config.guild(ctx.guild).addrole_whitelist()
if not addrole_whitelist: if not addrole_whitelist: