From 837fd10984332cd01bdcfab3cd5ce5e22bf6529d Mon Sep 17 00:00:00 2001 From: indifferentketchup Date: Tue, 19 May 2026 20:20:03 +0000 Subject: [PATCH] =?UTF-8?q?escalation:=20drop=20dead=20'reason'=20param=20?= =?UTF-8?q?=E2=80=94=20never=20populated,=20always=20logged=20as=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The /escalate slash command never had a reason option in its definition (commands/register.js only takes a 'level' option), so handleEscalate hardcoded reason=null. The escalate button path passed null explicitly. The log line wrote it verbatim as "Reason: null" on every escalate. Remove the dead surface: - runEscalation signature drops the reason parameter. - The customer-facing email body drops the conditional reason suffix (`reason ? `\n\nReason: ${reason}` : ''`) — always-false branch. - The logging-channel post drops "\nReason: ${reason}". - handleEscalate drops the `const reason = null;` line and the call-site arg. - handleEscalateButton (handlers/buttons.js) drops the trailing `null` arg. If we ever want to capture a reason, the slash command would need a StringOption('reason') and an escalate-modal for the button path — neither exists today. --- handlers/buttons.js | 2 +- handlers/commands/escalation.js | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/handlers/buttons.js b/handlers/buttons.js index fda8d95..0bee532 100644 --- a/handlers/buttons.js +++ b/handlers/buttons.js @@ -370,7 +370,7 @@ async function handleEscalateButton(interaction, ticket) { }); } - await runDeferred(interaction, 'escalate', () => runEscalation(interaction, ticket, tier, null)); + await runDeferred(interaction, 'escalate', () => runEscalation(interaction, ticket, tier)); } async function handleDeescalateButton(interaction, ticket) { diff --git a/handlers/commands/escalation.js b/handlers/commands/escalation.js index eff5323..f1ebede 100644 --- a/handlers/commands/escalation.js +++ b/handlers/commands/escalation.js @@ -23,7 +23,7 @@ const Ticket = mongoose.model('Ticket'); * Run escalation to a target tier (1 = tier 2, 2 = tier 3). Caller must * validate ticket and currentTier < nextTier, and have already deferred. */ -async function runEscalation(interaction, ticket, nextTier, reason) { +async function runEscalation(interaction, ticket, nextTier) { const isDiscordTicket = ticket.gmailThreadId.startsWith('discord-'); const categoryId = nextTier === 1 ? (isDiscordTicket ? CONFIG.DISCORD_ESCALATED2_CHANNEL_ID : CONFIG.EMAIL_ESCALATED2_CHANNEL_ID) @@ -87,7 +87,7 @@ async function runEscalation(interaction, ticket, nextTier, reason) { try { const escalatorName = interaction.member?.displayName || interaction.user.username; const tierLabel = nextTier === 1 ? 'tier 2' : 'tier 3'; - const emailBody = `${escalatorName} escalated this ticket to ${tierLabel}.${reason ? `\n\nReason: ${reason}` : ''}`; + const emailBody = `${escalatorName} escalated this ticket to ${tierLabel}.`; await sendTicketNotificationEmail(ticket, null, emailBody, interaction.user.id); } catch (emailErr) { console.error('Escalation email failed (non-fatal):', emailErr.message); @@ -108,7 +108,7 @@ async function runEscalation(interaction, ticket, nextTier, reason) { const ticketType = isDiscordTicket ? 'Discord' : 'Email'; const tierLabel = nextTier === 1 ? 'tier 2' : 'tier 3'; await enqueueSend(logChan, - `${ticketType} ticket ${interaction.channel} escalated to ${tierLabel} by ${interaction.user.tag}.\nReason: ${reason}` + `${ticketType} ticket ${interaction.channel} escalated to ${tierLabel} by ${interaction.user.tag}.` ); } } @@ -164,7 +164,6 @@ async function runDeescalation(interaction, ticket) { } async function handleEscalate(interaction) { - const reason = null; const level = interaction.options.getString('level'); const nextTier = level === '3' ? 2 : 1; @@ -192,7 +191,7 @@ async function handleEscalate(interaction) { } await runDeferred(interaction, 'escalate', () => - runEscalation(interaction, ticket, nextTier, reason) + runEscalation(interaction, ticket, nextTier) ); }