import genshindb from "genshin-db";
const handler = async (m, { conn, text, usedPrefix, command }) => {
  if (!text)
    throw `Contoh: *${usedPrefix + command} mondstadt*\nHarap berikan nama prestasi.`;
  try {
    let result = await genshindb.achievements(text);
    if (result) {
      let response = `*${result.name}*\n`;
      response += `_${result.description}_\n\n`;
      response += `*Kategori:* ${result.category || ""}\n`;
      response += `*Rarity:* ${result.rarity || ""}\n`;
      response += `*Detail:* ${result.detail || ""}\n`;
      response += `*Cara Mendapatkan:* ${result.howToObtain || ""}\n`;
      m.reply(response);
    } else {
      throw new Error("Prestasi tidak ditemukan.");
    }
  } catch (error) {
    console.error(error);
    let available = await genshindb.achievements("names", {
      matchCategories: true,
    });
    m.reply(
      `*Tidak Ditemukan*\n\n*Prestasi yang tersedia:* ${available.join(", ")}`,
    );
  }
};
handler.help = ["giachievement <nama prestasi>"];
handler.tags = ["genshin"];
handler.command = /^((gi|genshin)(achievements?|achievements?))$/i;
handler.limit = true;
export default handler;
