Files
broccolini-bot/utils/ticketComponents.js
root 519788c633 Initial commit
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 08:22:19 -06:00

52 lines
1.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 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 };