Add action to existing open case if one exists
This commit is contained in:
parent
692200ea47
commit
3eee7aa2a3
2 changed files with 13 additions and 2 deletions
|
@ -673,7 +673,11 @@ class Jarvis(Client):
|
||||||
admin=context.author.id, content="Moderation case opened via message"
|
admin=context.author.id, content="Moderation case opened via message"
|
||||||
)
|
)
|
||||||
modlog = Modlog(
|
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()
|
await modlog.commit()
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from jarvis_core.db import q
|
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 import Client, Cog, InteractionContext
|
||||||
from naff.models.discord.components import ActionRow, Button, ButtonStyles
|
from naff.models.discord.components import ActionRow, Button, ButtonStyles
|
||||||
from naff.models.discord.embed import EmbedField
|
from naff.models.discord.embed import EmbedField
|
||||||
|
@ -69,6 +69,13 @@ class ModcaseCog(Cog):
|
||||||
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")
|
||||||
|
|
||||||
|
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}"
|
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):
|
||||||
|
|
Loading…
Add table
Reference in a new issue