fix(aurora): add a resolve_handler to AddRole (oops!)
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Failing after 29s
Actions / Lint Code (Ruff & Pylint) (pull_request) Successful in 44s

This commit is contained in:
Seaswimmer 2024-07-12 16:30:34 -04:00
parent b379584251
commit 6edda87baa
Signed by: cswimr
GPG key ID: 3813315477F26F82

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: