(settings, roles, guild, client)
| 38 | import { setLogChannel, resolveApplicationLogChannel, resolveLogChannel } from '../../../services/loggingService.js'; |
| 39 | |
| 40 | async function buildDashboardEmbed(settings, roles, guild, client) { |
| 41 | const guildConfig = await getGuildConfig(client, guild.id); |
| 42 | const applicationsChannel = resolveLogChannel(guildConfig, 'applications') || settings.logChannelId; |
| 43 | const logChannel = applicationsChannel ? `<#${applicationsChannel}>` : '`Not set`'; |
| 44 | const managerRoleList = |
| 45 | settings.managerRoles?.length > 0 |
| 46 | ? settings.managerRoles.map(id => `<@&${id}>`).join(',') |
| 47 | : '`None configured`'; |
| 48 | const roleList = |
| 49 | roles.length > 0 |
| 50 | ? roles.map(r => `<@&${r.roleId}> — ${r.name}`).join('\n') |
| 51 | : '`No application roles configured`'; |
| 52 | const questionCount = settings.questions?.length ?? 0; |
| 53 | const firstQ = |
| 54 | settings.questions?.[0] |
| 55 | ? `\`${settings.questions[0].length > 55 ? settings.questions[0].substring(0, 55) + '…' : settings.questions[0]}\`` |
| 56 | : '`Not set`'; |
| 57 | |
| 58 | return new EmbedBuilder() |
| 59 | .setTitle('Applications Dashboard') |
| 60 | .setDescription(`Manage application settings for **${guild.name}**.\nSelect an option below to modify a setting.`) |
| 61 | .setColor(getColor('info')) |
| 62 | .addFields( |
| 63 | { name: 'Application Status', value: settings.enabled ? 'Enabled' : 'Disabled', inline: true }, |
| 64 | { name: 'Log Channel', value: logChannel, inline: true }, |
| 65 | { name: '\u200B', value: '\u200B', inline: true }, |
| 66 | { name: 'Manager Roles', value: managerRoleList, inline: false }, |
| 67 | { name: 'Questions', value: `${questionCount} configured — first: ${firstQ}`, inline: false }, |
| 68 | { name: 'Application Roles', value: roleList, inline: false }, |
| 69 | { |
| 70 | name: 'Retention', |
| 71 | value: `Pending: **${settings.pendingApplicationRetentionDays ?? 30}d** · Reviewed: **${settings.reviewedApplicationRetentionDays ?? 14}d**`, |
| 72 | inline: false, |
| 73 | }, |
| 74 | ) |
| 75 | .setFooter({ text: 'Dashboard closes after 15 minutes of inactivity' }) |
| 76 | .setTimestamp(); |
| 77 | } |
| 78 | |
| 79 | function buildSelectMenu(guildId) { |
| 80 | return new StringSelectMenuBuilder() |
no test coverage detected