feat(moderation): expired moderations are now automaticaly marked as such
This commit is contained in:
parent
4083e1890e
commit
11da49202d
1 changed files with 13 additions and 0 deletions
|
@ -4,6 +4,7 @@ from datetime import datetime, timedelta, timezone
|
||||||
import discord
|
import discord
|
||||||
import humanize
|
import humanize
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
|
from discord.ext import tasks
|
||||||
from pytimeparse2 import disable_dateutil, parse
|
from pytimeparse2 import disable_dateutil, parse
|
||||||
from redbot.core import app_commands, checks, Config, commands
|
from redbot.core import app_commands, checks, Config, commands
|
||||||
from redbot.core.app_commands import Choice
|
from redbot.core.app_commands import Choice
|
||||||
|
@ -397,6 +398,18 @@ class Moderation(commands.Cog):
|
||||||
else:
|
else:
|
||||||
await interaction.response.send_message(content=f"No case with case number `{case_number}` found.", ephemeral=True)
|
await interaction.response.send_message(content=f"No case with case number `{case_number}` found.", ephemeral=True)
|
||||||
|
|
||||||
|
@tasks.loop(minutes=1)
|
||||||
|
async def handle_expiry(self):
|
||||||
|
conf = await self.check_conf(['mysql_database'])
|
||||||
|
if conf:
|
||||||
|
return
|
||||||
|
database = await self.connect()
|
||||||
|
cursor = database.cursor()
|
||||||
|
query = f"UPDATE {await self.config.mysql_database()}.* SET expired = 1 WHERE end_timestamp <= %s AND expired = 0"
|
||||||
|
cursor.execute(query, (time.time(),))
|
||||||
|
database.commit()
|
||||||
|
cursor.close()
|
||||||
|
database.close()
|
||||||
|
|
||||||
@commands.group(autohelp=True)
|
@commands.group(autohelp=True)
|
||||||
@checks.admin()
|
@checks.admin()
|
||||||
|
|
Loading…
Reference in a new issue