MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / handleVerificationButton

Function handleVerificationButton

src/handlers/verificationButtons.js:8–64  ·  view source on GitHub ↗
(interaction, client)

Source from the content-addressed store, hash-verified

6import { InteractionHelper } from '../utils/interactionHelper.js';
7
8export async function handleVerificationButton(interaction, client) {
9 try {
10 await InteractionHelper.safeDefer(interaction, { flags: MessageFlags.Ephemeral });
11
12 if (!interaction.guild) {
13 return await replyUserError(interaction, { type: ErrorTypes.UNKNOWN, message: 'This button can only be used in a server.' });
14 }
15
16 const guild = interaction.guild;
17 const userId = interaction.user.id;
18
19 logger.debug('User clicked verify button', {
20 guildId: guild.id,
21 userId,
22 userTag: interaction.user.tag
23 });
24
25 const result = await verifyUser(client, guild.id, userId, {
26 source: 'button_click',
27 moderatorId: null
28 });
29
30 if (!result.success) {
31 if (result.alreadyVerified) {
32 return await replyUserError(interaction, { type: ErrorTypes.UNKNOWN, message: 'You are already verified and have access to all server channels.' });
33 }
34
35 return await replyUserError(interaction, { type: ErrorTypes.UNKNOWN, message: 'An error occurred during verification. Please try again or contact an administrator.' });
36 }
37
38 logger.info('User verified via button', {
39 guildId: guild.id,
40 userId,
41 roleName: result.roleName
42 });
43
44 await InteractionHelper.safeEditReply(interaction, {
45 embeds: [successEmbed(
46 "✅ Verification Successful!",
47 `You have been verified and given the **${result.roleName}** role!\n\nYou now have access to all server channels and features. Welcome! 🎉`
48 )],
49 });
50
51 } catch (error) {
52 logger.error('Error in verification button handler', {
53 error: error.message,
54 guildId: interaction.guild?.id,
55 userId: interaction.user.id
56 });
57
58 await handleInteractionError(
59 interaction,
60 error,
61 { command: 'verify_button', action: 'verification' }
62 );
63 }
64}
65

Callers

nothing calls this directly

Calls 6

verifyUserFunction · 0.90
successEmbedFunction · 0.90
handleInteractionErrorFunction · 0.90
replyUserErrorFunction · 0.85
safeDeferMethod · 0.80
safeEditReplyMethod · 0.80

Tested by

no test coverage detected