Skip to content

Commit

Permalink
fix: Send mod log after executer for dm message components
Browse files Browse the repository at this point in the history
  • Loading branch information
tzushimelon committed Mar 8, 2024
1 parent 86abb4c commit 22dfb8f
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions packages/sushii-worker/src/interactions/moderation/executeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ async function execActionUser(
data: ModActionData,
target: ModActionTarget,
actionType: ActionType,
modCase: AllSelection<DB, "app_public.mod_logs">,
): Promise<Result<ModActionTarget, ActionError>> {
if (!interaction.inCachedGuild()) {
throw new Error("Interaction is not in guild");
Expand All @@ -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: {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -459,7 +441,6 @@ async function executeActionUser(
data,
target,
actionType,
modLog,
);

// DM after for non-ban and send dm
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 22dfb8f

Please sign in to comment.