Add action to existing open case if one exists

This commit is contained in:
Zeva Rose 2022-05-03 08:45:13 -06:00
parent 692200ea47
commit 3eee7aa2a3
2 changed files with 13 additions and 2 deletions

View file

@ -673,7 +673,11 @@ class Jarvis(Client):
admin=context.author.id, content="Moderation case opened via message"
)
modlog = Modlog(
user=user.id, admin=context.author.id, actions=[action], notes=[note]
user=user.id,
admin=context.author.id,
guild=context.guild.id,
actions=[action],
notes=[note],
)
await modlog.commit()

View file

@ -3,7 +3,7 @@ import logging
from datetime import timedelta
from jarvis_core.db import q
from jarvis_core.db.models import Ban, Kick, Mute, Setting, Warning
from jarvis_core.db.models import Action, Ban, Kick, Modlog, Mute, Setting, Warning
from naff import Client, Cog, InteractionContext
from naff.models.discord.components import ActionRow, Button, ButtonStyles
from naff.models.discord.embed import EmbedField
@ -69,6 +69,13 @@ class ModcaseCog(Cog):
except Exception:
self.logger.debug("User not warned of action due to closed DMs")
modlog = await Modlog.find_onw(q(user=user.id, guild=ctx.guild.id, open=True))
if modlog:
m_action = Action(action_type=name.lower(), parent=action.id)
modlog.actions.append(m_action)
await modlog.commit()
return
lookup_key = f"{user.id}|{ctx.guild.id}"
async with self.bot.redis.lock("lock|" + lookup_key):