Re-introduce moderation log activity logging
This commit is contained in:
parent
f906886512
commit
e2c3ba98a5
2 changed files with 28 additions and 9 deletions
|
@ -36,9 +36,10 @@ def build_embed(
|
||||||
def modlog_embed(
|
def modlog_embed(
|
||||||
member: Member,
|
member: Member,
|
||||||
admin: Member,
|
admin: Member,
|
||||||
log: AuditLogEntry,
|
|
||||||
title: str,
|
title: str,
|
||||||
desc: str,
|
desc: str,
|
||||||
|
log: AuditLogEntry = None,
|
||||||
|
reason: str = None,
|
||||||
) -> Embed:
|
) -> Embed:
|
||||||
"""Get modlog embed."""
|
"""Get modlog embed."""
|
||||||
fields = [
|
fields = [
|
||||||
|
@ -47,8 +48,9 @@ def modlog_embed(
|
||||||
value=f"{admin.mention} ({admin.username}#{admin.discriminator})",
|
value=f"{admin.mention} ({admin.username}#{admin.discriminator})",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
if log.reason:
|
if log and log.reason:
|
||||||
fields.append(EmbedField(name="Reason", value=log.reason, inline=False))
|
reason = reason or log.reason
|
||||||
|
fields.append(EmbedField(name="Reason", value=reason, inline=False))
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
title=title,
|
title=title,
|
||||||
description=desc,
|
description=desc,
|
||||||
|
|
|
@ -18,6 +18,7 @@ IGNORE_COMMANDS = {
|
||||||
"Mute": ["unmute"],
|
"Mute": ["unmute"],
|
||||||
"Warning": ["warnings"],
|
"Warning": ["warnings"],
|
||||||
}
|
}
|
||||||
|
VERB_LOOKUP = {"Ban": "banned", "Kick": "kicked", "Mute": "muted", "Warning": "warned"}
|
||||||
|
|
||||||
|
|
||||||
class ModcaseCog(Extension):
|
class ModcaseCog(Extension):
|
||||||
|
@ -79,7 +80,7 @@ class ModcaseCog(Extension):
|
||||||
embed.set_author(name=ctx.guild.name, icon_url=ctx.guild.icon.url, url=guild_url)
|
embed.set_author(name=ctx.guild.name, icon_url=ctx.guild.icon.url, url=guild_url)
|
||||||
embed.set_thumbnail(url=ctx.guild.icon.url)
|
embed.set_thumbnail(url=ctx.guild.icon.url)
|
||||||
try:
|
try:
|
||||||
await user.send(embed=embed)
|
await user.send(embeds=embed)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.logger.debug("User not warned of action due to closed DMs")
|
self.logger.debug("User not warned of action due to closed DMs")
|
||||||
|
|
||||||
|
@ -90,6 +91,26 @@ class ModcaseCog(Extension):
|
||||||
await modlog.commit()
|
await modlog.commit()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
modlog = await Setting.find_one(q(guild=ctx.guild.id, setting="modlog"))
|
||||||
|
if not modlog:
|
||||||
|
return
|
||||||
|
|
||||||
|
fields = (
|
||||||
|
EmbedField(name="Action Type", value=name, inline=False),
|
||||||
|
EmbedField(name="Reason", value=kwargs.get("reason", None) or "N/A", inline=False),
|
||||||
|
EmbedField(name="Admin", value=ctx.author.mention, inline=False),
|
||||||
|
)
|
||||||
|
embed = build_embed(
|
||||||
|
title="Admin action taken",
|
||||||
|
description=f"Admin action has been taken against {user.mention}",
|
||||||
|
fields=fields,
|
||||||
|
)
|
||||||
|
embed.set_author(
|
||||||
|
name=f"{user.username}#{user.discriminator}", icon_url=user.display_avatar.url
|
||||||
|
)
|
||||||
|
embed.set_footer(text=f"User ID: {user.id}")
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
lookup_key = f"{user.id}|{ctx.guild.id}"
|
lookup_key = f"{user.id}|{ctx.guild.id}"
|
||||||
|
|
||||||
async with self.bot.redis.lock("lock|" + lookup_key):
|
async with self.bot.redis.lock("lock|" + lookup_key):
|
||||||
|
@ -97,10 +118,6 @@ class ModcaseCog(Extension):
|
||||||
self.logger.debug(f"User {user.id} in {ctx.guild.id} already has pending case")
|
self.logger.debug(f"User {user.id} in {ctx.guild.id} already has pending case")
|
||||||
return
|
return
|
||||||
|
|
||||||
modlog = await Setting.find_one(q(guild=ctx.guild.id, setting="modlog"))
|
|
||||||
if not modlog:
|
|
||||||
return
|
|
||||||
|
|
||||||
channel = await ctx.guild.fetch_channel(modlog.value)
|
channel = await ctx.guild.fetch_channel(modlog.value)
|
||||||
if not channel:
|
if not channel:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
|
@ -124,7 +141,7 @@ class ModcaseCog(Extension):
|
||||||
Button(style=ButtonStyles.GREEN, emoji="✔️", custom_id="modcase|yes"),
|
Button(style=ButtonStyles.GREEN, emoji="✔️", custom_id="modcase|yes"),
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
message = await channel.send(embed=embed, components=components)
|
message = await channel.send(embeds=embed, components=components)
|
||||||
|
|
||||||
await self.bot.redis.set(
|
await self.bot.redis.set(
|
||||||
lookup_key, f"{name.lower()}|{action.id}", ex=timedelta(days=7)
|
lookup_key, f"{name.lower()}|{action.id}", ex=timedelta(days=7)
|
||||||
|
|
Loading…
Add table
Reference in a new issue