WIP: Refactor Aurora (3.0.0) #29
1 changed files with 18 additions and 3 deletions
|
@ -241,7 +241,12 @@ class AddRole(Type):
|
||||||
@classmethod
|
@classmethod
|
||||||
async def expiry_handler(cls, moderation: Moderation) -> int:
|
async def expiry_handler(cls, moderation: Moderation) -> int:
|
||||||
try:
|
try:
|
||||||
target = await moderation.get_target()
|
target = moderation.bot.get_user(moderation.target_id)
|
||||||
|
if not target:
|
||||||
|
try:
|
||||||
|
await moderation.guild.fetch_member(moderation.target_id)
|
||||||
|
except NotFound:
|
||||||
|
return 0
|
||||||
|
|
||||||
await target.remove_roles(
|
await target.remove_roles(
|
||||||
Object(moderation.role_id), reason=f"Automatic role removal from case #{moderation.id}"
|
Object(moderation.role_id), reason=f"Automatic role removal from case #{moderation.id}"
|
||||||
|
@ -409,7 +414,12 @@ class RemoveRole(Type):
|
||||||
@classmethod
|
@classmethod
|
||||||
async def expiry_handler(cls, moderation: Moderation) -> int:
|
async def expiry_handler(cls, moderation: Moderation) -> int:
|
||||||
try:
|
try:
|
||||||
target = await moderation.get_target()
|
target = moderation.bot.get_user(moderation.target_id)
|
||||||
|
if not target:
|
||||||
|
try:
|
||||||
|
await moderation.guild.fetch_member(moderation.target_id)
|
||||||
|
except NotFound:
|
||||||
|
return 0
|
||||||
|
|
||||||
await target.add_roles(
|
await target.add_roles(
|
||||||
Object(moderation.role_id), reason=f"Automatic role addition from case #{moderation.id}"
|
Object(moderation.role_id), reason=f"Automatic role addition from case #{moderation.id}"
|
||||||
|
@ -881,7 +891,12 @@ class Tempban(Ban):
|
||||||
async def expiry_handler(cls, moderation: Moderation) -> int:
|
async def expiry_handler(cls, moderation: Moderation) -> int:
|
||||||
reason = f"Automatic {Unban.string} from case #{moderation.id}"
|
reason = f"Automatic {Unban.string} from case #{moderation.id}"
|
||||||
try:
|
try:
|
||||||
target = await moderation.get_target()
|
target = moderation.bot.get_user(moderation.target_id)
|
||||||
|
if not target:
|
||||||
|
try:
|
||||||
|
await moderation.bot.fetch_user(moderation.target_id)
|
||||||
|
except NotFound:
|
||||||
|
return 0
|
||||||
await moderation.guild.unban(user=target, reason=reason)
|
await moderation.guild.unban(user=target, reason=reason)
|
||||||
|
|
||||||
if await config.guild(moderation.guild).dm_users() is True:
|
if await config.guild(moderation.guild).dm_users() is True:
|
||||||
|
|
Loading…
Reference in a new issue