This commit is contained in:
parent
2982b475ca
commit
c783f4032a
1 changed files with 48 additions and 1 deletions
|
@ -185,7 +185,7 @@ class Moderation(commands.Cog):
|
||||||
cursor.execute(f"SELECT moderation_id FROM `moderation_{guild_id}` ORDER BY moderation_id DESC LIMIT 1")
|
cursor.execute(f"SELECT moderation_id FROM `moderation_{guild_id}` ORDER BY moderation_id DESC LIMIT 1")
|
||||||
return cursor.fetchone()[0] + 1
|
return cursor.fetchone()[0] + 1
|
||||||
|
|
||||||
async def embed_factory(self, embed_type: str, guild: discord.Guild, reason: str, moderation_type: str, response: discord.InteractionMessage, duration: timedelta = None):
|
async def embed_factory(self, embed_type: str, guild: discord.Guild, reason: str, moderation_type: str, response: discord.InteractionMessage = None, duration: timedelta = None):
|
||||||
"""This method creates an embed from set parameters, meant for either moderation logging or contacting the moderated user.
|
"""This method creates an embed from set parameters, meant for either moderation logging or contacting the moderated user.
|
||||||
|
|
||||||
Valid arguments for 'embed_type':
|
Valid arguments for 'embed_type':
|
||||||
|
@ -350,6 +350,53 @@ class Moderation(commands.Cog):
|
||||||
pass
|
pass
|
||||||
await self.mysql_log(interaction.guild.id, interaction.user.id, 'UNBAN', target.id, 'NULL', reason)
|
await self.mysql_log(interaction.guild.id, interaction.user.id, 'UNBAN', target.id, 'NULL', reason)
|
||||||
|
|
||||||
|
@app_commands.command(name="case")
|
||||||
|
async def case(self, interaction: discord.Interaction, case_number: int, ephemeral: bool = False):
|
||||||
|
"""Check the details of a specific case."""
|
||||||
|
database = await self.connect()
|
||||||
|
cursor = database.cursor()
|
||||||
|
query = "SELECT * FROM moderation_%s WHERE moderation_id = %s;"
|
||||||
|
cursor.execute(query, (interaction.guild.id, case_number))
|
||||||
|
result = cursor.fetchone()
|
||||||
|
cursor.close()
|
||||||
|
database.close()
|
||||||
|
if result:
|
||||||
|
case = {
|
||||||
|
"moderation_id": result[0],
|
||||||
|
"timestamp": result[1],
|
||||||
|
"moderation_type": result[2],
|
||||||
|
"target_id": result[3],
|
||||||
|
"moderator_id": result[4],
|
||||||
|
"duration": result[5],
|
||||||
|
"end_timestamp": result[6],
|
||||||
|
"reason": result[7],
|
||||||
|
"resolved": result[8],
|
||||||
|
"resolve_reason": result[9],
|
||||||
|
"expired": result[10]
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
target = interaction.client.get_user(case["target_id"])
|
||||||
|
except discord.errors.NotFound:
|
||||||
|
target = discord.User(id=case["target_id"], name="Deleted User", discriminator="0")
|
||||||
|
try:
|
||||||
|
moderator = interaction.client.get_user(case["moderator_id"])
|
||||||
|
except discord.errors.NotFound:
|
||||||
|
moderator = discord.User(id=case["moderator_id"], name="Deleted User", discriminator="0")
|
||||||
|
target_name = target.name if target.discriminator == "0" else f"{target.name}#{target.discriminator}"
|
||||||
|
moderator_name = moderator.name if moderator.discriminator == "0" else f"{moderator.name}#{moderator.discriminator}"
|
||||||
|
embed = discord.Embed(title=f"📕 Case #{case['moderation_id']} - {str.title(case['moderation_type'])}", color=await self.bot.get_embed_color(None))
|
||||||
|
embed.description = f"**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() else False
|
||||||
|
embed.description = embed.description + f"**Duration:** {humanize.naturaldelta(case['duration'])}\n**Expired:** {expired}"
|
||||||
|
embed.add_field(name='Reason', value=f"```{case['reason']}```")
|
||||||
|
if case['resolved'] == 1:
|
||||||
|
embed.add_field(name='Resolve Reason', value=f"```{case['resolve_reason']}```")
|
||||||
|
await interaction.response.send_message(embed=embed, ephemeral=ephemeral)
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message(content=f"No case with case number `{case_number}` found.", ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
@commands.group(autohelp=True)
|
@commands.group(autohelp=True)
|
||||||
@checks.admin()
|
@checks.admin()
|
||||||
async def moderationset(self, ctx: commands.Context):
|
async def moderationset(self, ctx: commands.Context):
|
||||||
|
|
Loading…
Reference in a new issue