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

Function execute

src/commands/Utility/modules/report.js:10–68  ·  view source on GitHub ↗
(interaction, config, client)

Source from the content-addressed store, hash-verified

8
9export default {
10 async execute(interaction, config, client) {
11 const deferSuccess = await InteractionHelper.safeDefer(interaction, { ephemeral: true });
12 if (!deferSuccess) {
13 logger.warn('Report interaction defer failed', { userId: interaction.user.id, guildId: interaction.guildId });
14 return;
15 }
16
17 const targetUser = interaction.options.getUser('user');
18 const reason = interaction.options.getString('reason');
19 const guildId = interaction.guildId;
20
21 const guildConfig = await getGuildConfig(client, guildId);
22 const reportChannelId = resolveLogChannel(guildConfig, 'reports');
23
24 if (!reportChannelId) {
25 return await replyUserError(interaction, { type: ErrorTypes.UNKNOWN, message: 'The report channel has not been set up. Ask a moderator to use `/logging dashboard` or `/logging channel`.' });
26 }
27
28 try {
29 const ownerMention = interaction.guild.ownerId
30 ? `<@${interaction.guild.ownerId}> New report!`
31 : 'New report!';
32
33 await logEvent({
34 client,
35 guildId,
36 eventType: EVENT_TYPES.REPORT_FILE,
37 content: ownerMention,
38 data: {
39 title: 'User Report',
40 lines: [
41 formatLogLine('Reported User', `${targetUser.tag} (\`${targetUser.id}\`)`),
42 formatLogLine('Reported By', `${interaction.user.tag} (\`${interaction.user.id}\`)`),
43 formatLogLine('Channel', interaction.channel.toString()),
44 ],
45 blockFields: [{ name: 'Reason', value: reason }],
46 author: await resolveUserAuthor(client, targetUser.id),
47 thumbnail: targetUser.displayAvatarURL(),
48 },
49 });
50
51 await InteractionHelper.safeEditReply(interaction, {
52 embeds: [createEmbed({
53 title: 'Report Submitted',
54 description: `Your report against **${targetUser.tag}** has been successfully filed and sent to the moderation team. Thank you!`,
55 })],
56 });
57
58 logger.info('Report submitted', {
59 userId: interaction.user.id,
60 reportedUserId: targetUser.id,
61 guildId,
62 reasonLength: reason.length,
63 });
64 } catch (error) {
65 logger.error('report error:', error);
66 await handleInteractionError(interaction, error, { commandName: 'report', source: 'report' });
67 }

Callers

nothing calls this directly

Calls 10

getGuildConfigFunction · 0.90
resolveLogChannelFunction · 0.90
logEventFunction · 0.90
formatLogLineFunction · 0.90
resolveUserAuthorFunction · 0.90
createEmbedFunction · 0.90
handleInteractionErrorFunction · 0.90
replyUserErrorFunction · 0.85
safeDeferMethod · 0.80
safeEditReplyMethod · 0.80

Tested by

no test coverage detected