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

Function logTicketEvent

src/utils/ticketLogging.js:12–52  ·  view source on GitHub ↗
({ client, guildId, event })

Source from the content-addressed store, hash-verified

10} from './logEmbeds.js';
11
12export async function logTicketEvent({ client, guildId, event }) {
13 try {
14 const guild = client.guilds.cache.get(guildId) || await client.guilds.fetch(guildId).catch(() => null);
15 if (!guild) {
16 logger.warn(`logTicketEvent invoked without valid guild: ${guildId}`);
17 return;
18 }
19
20 const config = await getGuildConfig(client, guildId);
21
22 const logChannelId = getLogChannelForEventType(config, event.type);
23 if (!logChannelId) {
24 return;
25 }
26
27 const channel = guild.channels.cache.get(logChannelId) || await guild.channels.fetch(logChannelId).catch(() => null);
28 if (!channel) {
29 logger.warn(`Ticket log channel not found: ${logChannelId} for event type: ${event.type}`);
30 return;
31 }
32
33 const permissions = channel.permissionsFor(guild.members.me);
34 if (!permissions.has(['SendMessages', 'EmbedLinks'])) {
35 logger.warn(`Missing permissions in ticket log channel: ${logChannelId}`);
36 return;
37 }
38
39 const embed = await createTicketLogEmbed(guild, event);
40
41 const messageOptions = { embeds: [embed] };
42
43 if (event.attachments && event.attachments.length > 0) {
44 messageOptions.files = event.attachments;
45 }
46
47 await channel.send(messageOptions);
48 logger.info(`Ticket event logged: ${event.type} in guild ${guildId}`);
49 } catch (error) {
50 logger.error('Error logging ticket event:', error);
51 }
52}
53
54export async function logTicketFeedback({
55 client,

Callers 8

createTicketFunction · 0.90
closeTicketFunction · 0.90
claimTicketFunction · 0.90
deleteTicketFunction · 0.90
unclaimTicketFunction · 0.90
updateTicketPriorityFunction · 0.90
executeFunction · 0.90
logTicketFeedbackFunction · 0.85

Calls 4

getGuildConfigFunction · 0.90
createTicketLogEmbedFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected