const { handleLinkCommand } = require('./commands');
const discordRoleSync = require('../services/discordRoleSync');

function registerEvents(client) {
  client.on('interactionCreate', async interaction => {
    if (!interaction.isChatInputCommand()) return;
    if (interaction.commandName === 'link') {
      await handleLinkCommand(interaction);
    }
  });

  client.on('ready', () => {
    console.log(`Discord bot logged in as ${client.user.tag}`);
    // Initialize role sync service with the ready client
    discordRoleSync.init(client);
  });
}

module.exports = { registerEvents };
