escalation: drop dead 'reason' param — never populated, always logged as null
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.
This commit is contained in:
@@ -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) {
|
async function handleDeescalateButton(interaction, ticket) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const Ticket = mongoose.model('Ticket');
|
|||||||
* Run escalation to a target tier (1 = tier 2, 2 = tier 3). Caller must
|
* Run escalation to a target tier (1 = tier 2, 2 = tier 3). Caller must
|
||||||
* validate ticket and currentTier < nextTier, and have already deferred.
|
* 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 isDiscordTicket = ticket.gmailThreadId.startsWith('discord-');
|
||||||
const categoryId = nextTier === 1
|
const categoryId = nextTier === 1
|
||||||
? (isDiscordTicket ? CONFIG.DISCORD_ESCALATED2_CHANNEL_ID : CONFIG.EMAIL_ESCALATED2_CHANNEL_ID)
|
? (isDiscordTicket ? CONFIG.DISCORD_ESCALATED2_CHANNEL_ID : CONFIG.EMAIL_ESCALATED2_CHANNEL_ID)
|
||||||
@@ -87,7 +87,7 @@ async function runEscalation(interaction, ticket, nextTier, reason) {
|
|||||||
try {
|
try {
|
||||||
const escalatorName = interaction.member?.displayName || interaction.user.username;
|
const escalatorName = interaction.member?.displayName || interaction.user.username;
|
||||||
const tierLabel = nextTier === 1 ? 'tier 2' : 'tier 3';
|
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);
|
await sendTicketNotificationEmail(ticket, null, emailBody, interaction.user.id);
|
||||||
} catch (emailErr) {
|
} catch (emailErr) {
|
||||||
console.error('Escalation email failed (non-fatal):', emailErr.message);
|
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 ticketType = isDiscordTicket ? 'Discord' : 'Email';
|
||||||
const tierLabel = nextTier === 1 ? 'tier 2' : 'tier 3';
|
const tierLabel = nextTier === 1 ? 'tier 2' : 'tier 3';
|
||||||
await enqueueSend(logChan,
|
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) {
|
async function handleEscalate(interaction) {
|
||||||
const reason = null;
|
|
||||||
const level = interaction.options.getString('level');
|
const level = interaction.options.getString('level');
|
||||||
const nextTier = level === '3' ? 2 : 1;
|
const nextTier = level === '3' ? 2 : 1;
|
||||||
|
|
||||||
@@ -192,7 +191,7 @@ async function handleEscalate(interaction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await runDeferred(interaction, 'escalate', () =>
|
await runDeferred(interaction, 'escalate', () =>
|
||||||
runEscalation(interaction, ticket, nextTier, reason)
|
runEscalation(interaction, ticket, nextTier)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user