import { Events, Message } from 'discord.js';
import { MimicService } from '../services/MimicService';
import { BigEmojiService } from '../services/BigEmojiService';
import { prisma } from '../database';
import { ActivityTrackerService } from '../services/ActivityTrackerService';

export default {
  name: Events.MessageCreate,
  once: false,
  async execute(message: Message) {
    if (!message.guildId || message.author.bot) return;

    // 활동 추적 기록
    await ActivityTrackerService.recordActivity(message.guildId);

    const config = await prisma.guildConfig.findUnique({
      where: { guildId: message.guildId }
    });

    if (config?.bigEmojiEnabled) {
      await BigEmojiService.handleMessage(message);
    }
    
    if (config?.mimicEnabled) {
      await MimicService.handleMessage(message);
    }
  },
};
