jarvis-bot/jarvis/tasks/unwarn.py

16 lines
459 B
Python

"""J.A.R.V.I.S. unwarn background task handler."""
from datetime import datetime, timedelta
from discord.ext.tasks import loop
from jarvis.db.models import Warning
@loop(hours=1)
async def unwarn() -> None:
"""J.A.R.V.I.S. unwarn background task."""
warns = Warning.objects(active=True)
for warn in warns:
if warn.created_at + timedelta(hours=warn.duration) < datetime.utcnow():
warn.active = False
warn.save()