const fs = require("fs");
const path = require("path");

const rewardMap = new Map();

function loadRewards() {
  const files = fs.readdirSync(__dirname);

  for (const file of files) {
    if (file === "index.js") continue;

    const reward = require(path.join(__dirname, file));

    rewardMap.set(reward.name.toLowerCase(), reward.run);

    console.log(`📦 Loaded reward: ${reward.name}`);
  }
}

function getReward(name) {
  return rewardMap.get(name.toLowerCase());
}

loadRewards();

module.exports = { getReward };