From 22dfb8f3c1d673fc00a72b63cc6a01bc12a80f5b Mon Sep 17 00:00:00 2001 From: tzushimelon <4021761+tzushimelon@users.noreply.github.com> Date: Thu, 7 Mar 2024 17:21:07 -0800 Subject: [PATCH] fix: Send mod log after executer for dm message components --- .../interactions/moderation/executeAction.ts | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/packages/sushii-worker/src/interactions/moderation/executeAction.ts b/packages/sushii-worker/src/interactions/moderation/executeAction.ts index 4096b41..8bf1e19 100644 --- a/packages/sushii-worker/src/interactions/moderation/executeAction.ts +++ b/packages/sushii-worker/src/interactions/moderation/executeAction.ts @@ -153,7 +153,6 @@ async function execActionUser( data: ModActionData, target: ModActionTarget, actionType: ActionType, - modCase: AllSelection, ): Promise> { if (!interaction.inCachedGuild()) { throw new Error("Interaction is not in guild"); @@ -163,8 +162,6 @@ async function execActionUser( // Audit log header max 512 characters const auditLogReason = data.reason?.slice(0, 512); - const guildConfig = await getGuildConfig(db, interaction.guildId); - try { switch (actionType) { case ActionType.Kick: { @@ -262,29 +259,14 @@ async function execActionUser( }); } - await sendModLog( - ctx, - interaction, - guildConfig, - actionType, - target, - modCase, - ); + // Send to mod log only -- done after this function break; } case ActionType.Note: { // Allow for non-members, send no DM - // Send to mod log only - await sendModLog( - ctx, - interaction, - guildConfig, - actionType, - target, - modCase, - ); + // Send to mod log only -- done after this function break; } @@ -459,7 +441,6 @@ async function executeActionUser( data, target, actionType, - modLog, ); // DM after for non-ban and send dm @@ -526,6 +507,21 @@ async function executeActionUser( } }); + // Send mod log if needed - warn / note + // AFTER: DM was sent (warn) so the components are created properly + if (actionType === ActionType.Warn || actionType === ActionType.Note) { + const guildConfig = await getGuildConfig(db, interaction.guildId); + + await sendModLog( + ctx, + interaction, + guildConfig, + actionType, + target, + modLog, + ); + } + return Ok({ user: target.user, shouldDM,