// Automated content-filter hits (Phase 6b). Bot-owned; recorded whenever the
// word filter or foreign-invite filter deletes a message. mod_actions still
// records the resulting warn/mute separately. Schema: server/db/schema.sql
// (filter_hits).
const db = require('../db')

async function record({ guildId, hitType, discordUserId, username, channelId, matched, actionTaken }) {
  await db.query(
    `INSERT INTO filter_hits (guild_id, hit_type, discord_user_id, username, channel_id, matched, action_taken)
     VALUES (?, ?, ?, ?, ?, ?, ?)`,
    [guildId, hitType, discordUserId, username || null, channelId || null, matched || null, actionTaken],
  )
}

module.exports = { record }
