Update warnings

This commit is contained in:
Zeva Rose 2022-04-20 10:14:22 -06:00
parent cac3695351
commit 46a9f0342c
2 changed files with 15 additions and 1 deletions

View file

@ -2,7 +2,7 @@
import logging
import re
import traceback
from datetime import datetime, timezone
from datetime import datetime, timedelta, timezone
from aiohttp import ClientSession
from dis_snek import Snake, listen
@ -312,10 +312,13 @@ class Jarvis(Snake):
await message.delete()
except Exception:
self.logger.debug("Message deleted before action taken")
expires_at = datetime.now(tz=timezone.utc) + timedelta(hours=24)
await Warning(
active=True,
admin=self.user.id,
duration=24,
expires_at=expires_at,
guild=message.guild.id,
reason="Sent an invite link",
user=message.author.id,
@ -342,10 +345,12 @@ class Jarvis(Snake):
self.logger.debug(
f"Massmention threshold on {message.guild.id}/{message.channel.id}/{message.id}"
)
expires_at = datetime.now(tz=timezone.utc) + timedelta(hours=24)
await Warning(
active=True,
admin=self.user.id,
duration=24,
expires_at=expires_at,
guild=message.guild.id,
reason="Mass Mention",
user=message.author.id,
@ -398,10 +403,12 @@ class Jarvis(Snake):
self.logger.debug(
f"Rolepinged role in {message.guild.id}/{message.channel.id}/{message.id}"
)
expires_at = datetime.now(tz=timezone.utc) + timedelta(hours=24)
await Warning(
active=True,
admin=self.user.id,
duration=24,
expires_at=expires_at,
guild=message.guild.id,
reason="Pinged a blocked role/user with a blocked role",
user=message.author.id,
@ -416,10 +423,12 @@ class Jarvis(Snake):
self.logger.debug(
f"Phishing url `{m}` detected in {message.guild.id}/{message.channel.id}/{message.id}"
)
expires_at = datetime.now(tz=timezone.utc) + timedelta(hours=24)
await Warning(
active=True,
admin=self.user.id,
duration=24,
expires_at=expires_at,
guild=message.guild.id,
reason="Phishing URL",
user=message.author.id,
@ -445,10 +454,12 @@ class Jarvis(Snake):
self.logger.debug(
f"Scam url `{match.string}` detected in {message.guild.id}/{message.channel.id}/{message.id}"
)
expires_at = datetime.now(tz=timezone.utc) + timedelta(hours=24)
await Warning(
active=True,
admin=self.user.id,
duration=24,
expires_at=expires_at,
guild=message.guild.id,
reason="Unsafe URL",
user=message.author.id,

View file

@ -1,5 +1,6 @@
"""JARVIS WarningCog."""
import logging
from datetime import datetime, timedelta, timezone
from dis_snek import InteractionContext, Permissions, Snake
from dis_snek.client.utils.misc_utils import get_all
@ -59,12 +60,14 @@ class WarningCog(ModcaseCog):
await ctx.send("User not in guild", ephemeral=True)
return
await ctx.defer()
expires_at = datetime.now(tz=timezone.utc) + timedelta(hours=duration)
await Warning(
user=user.id,
reason=reason,
admin=ctx.author.id,
guild=ctx.guild.id,
duration=duration,
expires_at=expires_at,
active=True,
).commit()
embed = warning_embed(user, reason)