({ client, guild, guildId, event })
| 70 | } |
| 71 | |
| 72 | export async function logEvent({ client, guild, guildId, event }) { |
| 73 | try { |
| 74 | if (!guild && guildId) { |
| 75 | guild = client.guilds.cache.get(guildId) || await client.guilds.fetch(guildId).catch(() => null); |
| 76 | } |
| 77 | if (!guild) { |
| 78 | logger.warn('logEvent invoked without valid guild or guildId'); |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | const eventType = ACTION_TO_EVENT_TYPE[event.action] || EVENT_TYPES.MODERATION_CONFIG; |
| 83 | const data = buildModerationLogData(event); |
| 84 | |
| 85 | await logAuditEvent({ |
| 86 | client, |
| 87 | guildId: guild.id, |
| 88 | eventType, |
| 89 | data, |
| 90 | }); |
| 91 | |
| 92 | logger.info(`Moderation action logged: ${event.action} by ${event.executor} on ${event.target} in guild ${guild.id}`); |
| 93 | } catch (error) { |
| 94 | logger.error('Error logging moderation event:', error); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | export async function generateCaseId(client, guildId) { |
| 99 | try { |
no test coverage detected