import { Events } from 'discord.js';
import { db } from '../core/db.js';

export default {
  name: Events.GuildCreate,
  async execute(guild) {
    db.prepare(`
      INSERT INTO guilds (guild_id, name, owner_id) VALUES (?, ?, ?)
      ON CONFLICT(guild_id) DO UPDATE SET name = excluded.name
    `).run(guild.id, guild.name, guild.ownerId);
    console.log(`➕ Joined guild: ${guild.name} (${guild.id})`);
  },
};
