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(
|
||||
member: Member,
|
||||
admin: Member,
|
||||
log: AuditLogEntry,
|
||||
title: str,
|
||||
desc: str,
|
||||
log: AuditLogEntry = None,
|
||||
reason: str = None,
|
||||
) -> Embed:
|
||||
"""Get modlog embed."""
|
||||
fields = [
|
||||
|
@ -47,8 +48,9 @@ def modlog_embed(
|
|||
value=f"{admin.mention} ({admin.username}#{admin.discriminator})",
|
||||
),
|
||||
]
|
||||
if log.reason:
|
||||
fields.append(EmbedField(name="Reason", value=log.reason, inline=False))
|
||||
if log and log.reason:
|
||||
reason = reason or log.reason
|
||||
fields.append(EmbedField(name="Reason", value=reason, inline=False))
|
||||
embed = build_embed(
|
||||
title=title,
|
||||
description=desc,
|
||||
|
|
|
@ -18,6 +18,7 @@ IGNORE_COMMANDS = {
|
|||
"Mute": ["unmute"],
|
||||
"Warning": ["warnings"],
|
||||
}
|
||||
VERB_LOOKUP = {"Ban": "banned", "Kick": "kicked", "Mute": "muted", "Warning": "warned"}
|
||||
|
||||
|
||||
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_thumbnail(url=ctx.guild.icon.url)
|
||||
try:
|
||||
await user.send(embed=embed)
|
||||
await user.send(embeds=embed)
|
||||
except Exception:
|
||||
self.logger.debug("User not warned of action due to closed DMs")
|
||||
|
||||
|
@ -90,6 +91,26 @@ class ModcaseCog(Extension):
|
|||
await modlog.commit()
|
||||
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}"
|
||||
|
||||
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")
|
||||
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)
|
||||
if not channel:
|
||||
self.logger.warn(
|
||||
|
@ -124,7 +141,7 @@ class ModcaseCog(Extension):
|
|||
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(
|
||||
lookup_key, f"{name.lower()}|{action.id}", ex=timedelta(days=7)
|
||||
|
|
Loading…
Add table
Reference in a new issue