fix(aurora): add a resolve_handler to AddRole (oops!)
This commit is contained in:
parent
b379584251
commit
6edda87baa
1 changed files with 34 additions and 2 deletions
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue