Compare commits

..

No commits in common. "db4826e2324b4ceed5f1f37a0758ab94974d5a0b" and "4083e1890e1da4c510bfa1e33d826fb7c1d0e1af" have entirely different histories.

View file

@ -4,7 +4,6 @@ from datetime import datetime, timedelta, timezone
import discord
import humanize
import mysql.connector
from discord.ext import tasks
from pytimeparse2 import disable_dateutil, parse
from redbot.core import app_commands, checks, Config, commands
from redbot.core.app_commands import Choice
@ -388,8 +387,9 @@ class Moderation(commands.Cog):
embed = discord.Embed(title=f"📕 Case #{case['moderation_id']}", color=await self.bot.get_embed_color(None))
embed.description = f"**Type:** {str.title(case['moderation_type'])}\n**Target:** {target_name} ({target.id})\n**Moderator:** {moderator_name} ({moderator.id})\n**Resolved:** {bool(case['resolved'])}\n**Timestamp:** <t:{case['timestamp']}> | <t:{case['timestamp']}:R>"
if case['duration'] != 'NULL':
expired = True if case["end_timestamp"] <= time.time() or case['resolved'] == 1 else False
td = timedelta(**{unit: int(val) for unit, val in zip(["hours", "minutes", "seconds"], case["duration"].split(":"))})
embed.description = embed.description + f"\n**Duration:** {humanize.precisedelta(td)}\n**Expired:** {case['expired']}"
embed.description = embed.description + f"\n**Duration:** {humanize.precisedelta(td)}\n**Expired:** {expired}"
embed.add_field(name='Reason', value=f"```{case['reason']}```", inline=False)
if case['resolved'] == 1:
embed.add_field(name='Resolve Reason', value=f"```{case['resolve_reason']}```", inline=False)
@ -397,18 +397,6 @@ class Moderation(commands.Cog):
else:
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)
@checks.admin()