/** * Ticket action row builder – Close, Claim, Escalate (if tier < 3), Deescalate (if tier >= 2). * Used by handlers/buttons.js and handlers/commands.js. */ const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const { CONFIG } = require('../config'); /** * Build the standard ticket action row (Close, Claim, optionally Escalate, optionally Deescalate). * @param {Object} ticket - Ticket with escalationTier (0, 1, 2) and optionally escalated * @param {Object} [options] - { unclaimLabel, unclaimEmoji } for claim button when ticket is claimed * @returns {ActionRowBuilder} */ function getTicketActionRow(ticket, options = {}) { const tier = ticket.escalationTier ?? (ticket.escalated ? 1 : 0); const row = new ActionRowBuilder(); row.addComponents( new ButtonBuilder() .setCustomId('close_ticket') .setLabel(CONFIG.BUTTON_LABEL_CLOSE) .setEmoji(CONFIG.BUTTON_EMOJI_CLOSE) .setStyle(ButtonStyle.Secondary), new ButtonBuilder() .setCustomId('claim_ticket') .setLabel(options.unclaimLabel ?? CONFIG.BUTTON_LABEL_CLAIM) .setEmoji(options.unclaimEmoji ?? CONFIG.BUTTON_EMOJI_CLAIM) .setStyle(ButtonStyle.Secondary) ); if (tier < 2) { row.addComponents( new ButtonBuilder() .setCustomId('escalate_ticket') .setLabel('Escalate') .setStyle(ButtonStyle.Secondary) ); } if (tier >= 1) { row.addComponents( new ButtonBuilder() .setCustomId('deescalate_ticket') .setLabel('Deescalate') .setStyle(ButtonStyle.Secondary) ); } return row; } module.exports = { getTicketActionRow };