/** * Cross-submodule helpers for handlers/commands/*. * * Lives at this level (not in index.js) so escalation.js, close.js, etc. can * import without creating circular dependencies with index.js. */ const { MessageFlags } = require('discord.js'); const { CONFIG } = require('../../config'); const { isStaff } = require('../../utils'); /** * Reply ephemeral and return true if the interaction is in a guild and the * user is not staff (so the caller should bail). */ async function requireStaffRole(interaction) { if (!interaction.guild) return false; if (!CONFIG.ROLE_ID_TO_PING && (!CONFIG.ADDITIONAL_STAFF_ROLES || CONFIG.ADDITIONAL_STAFF_ROLES.length === 0)) return false; if (isStaff(interaction.member)) return false; const roleMention = CONFIG.ROLE_ID_TO_PING ? `<@&${CONFIG.ROLE_ID_TO_PING}>` : 'support'; await interaction.reply({ content: `This command is only available to the support team (${roleMention}).`, flags: MessageFlags.Ephemeral }); return true; } /** Fetch the configured logging channel, or null if unset/missing. */ async function fetchLoggingChannel(client) { if (!CONFIG.LOGGING_CHANNEL_ID) return null; return client.channels.fetch(CONFIG.LOGGING_CHANNEL_ID).catch(() => null); } module.exports = { requireStaffRole, fetchLoggingChannel };