MCPcopy
hub / github.com/codebymitch/TitanBot / execute

Function execute

src/commands/Verification/modules/verification_dashboard.js:168–378  ·  view source on GitHub ↗
(interaction, config, client)

Source from the content-addressed store, hash-verified

166export default {
167 prefixOnly: false,
168 async execute(interaction, config, client) {
169 try {
170 const guildId = interaction.guild.id;
171 const guildConfig = await getGuildConfig(client, guildId);
172 const cfg = guildConfig.verification;
173
174 if (!cfg?.channelId) {
175 throw new TitanBotError(
176 'Verification not configured',
177 ErrorTypes.CONFIGURATION,
178 'The verification system has not been set up yet. Run `/verification setup` first.',
179 );
180 }
181
182 await InteractionHelper.safeDefer(interaction, { flags: MessageFlags.Ephemeral });
183
184 const selectMenu = buildSelectMenu(guildId);
185
186 let verifiedUserCount = 0;
187 let conflictSummary = '';
188
189 try {
190 const verifiedRole = interaction.guild.roles.cache.get(cfg.roleId);
191 if (verifiedRole) {
192 verifiedUserCount = verifiedRole.members.size;
193 }
194
195 const welcomeConfig = await getWelcomeConfig(client, guildId);
196 const autoVerifyEnabled = Boolean(guildConfig.verification?.autoVerify?.enabled);
197 const autoRoleConfigured = Boolean(guildConfig.autoRole) || (Array.isArray(welcomeConfig.roleIds) && welcomeConfig.roleIds.length > 0);
198
199 const conflicts = [
200 autoVerifyEnabled ? 'AutoVerify is enabled' : null,
201 autoRoleConfigured ? 'AutoRole is configured' : null
202 ].filter(Boolean);
203
204 if (conflicts.length > 0) {
205 conflictSummary = conflicts.join('\n');
206 }
207 } catch (error) {
208 logger.warn('Could not fetch verification dashboard details:', error.message);
209 }
210
211 await InteractionHelper.safeEditReply(interaction, {
212 embeds: [buildDashboardEmbed(cfg, interaction.guild, verifiedUserCount, conflictSummary)],
213 components: [
214 buildButtonRow(cfg, guildId),
215 new ActionRowBuilder().addComponents(selectMenu),
216 ],
217 flags: MessageFlags.Ephemeral,
218 });
219
220 const collector = interaction.channel.createMessageComponentCollector({
221 componentType: ComponentType.StringSelect,
222 filter: i =>
223 i.user.id === interaction.user.id && i.customId === `verif_cfg_${guildId}`,
224 time: 600_000,
225 });

Callers

nothing calls this directly

Calls 15

getGuildConfigFunction · 0.90
getWelcomeConfigFunction · 0.90
replyUserErrorFunction · 0.90
getColorFunction · 0.90
setGuildConfigFunction · 0.90
successEmbedFunction · 0.90
handleButtonTextFunction · 0.85
safeDeferMethod · 0.80
safeEditReplyMethod · 0.80
followUpMethod · 0.80
buildSelectMenuFunction · 0.70
buildDashboardEmbedFunction · 0.70

Tested by

no test coverage detected