import genshindb from "genshin-db";
const handler = async (m, { conn, text, usedPrefix, command }) => {
  if (!text)
    throw `Contoh: *${usedPrefix + command} claymore*\nHarap berikan nama senjata.`;
  try {
    let result = await genshindb.weapons(text);
    if (result) {
      let response =
        `*Senjata Ditemukan: ${result.name}*\n\n` +
        `_${result.description || "Data tidak tersedia"}_\n\n` +
        `*Rarity:* ${result.rarity || "Data tidak tersedia"}\n` +
        `*Type:* ${result.type || "Data tidak tersedia"}\n` +
        `*Base ATK:* ${result.baseAttack || "Data tidak tersedia"}\n` +
        `*Substat:* ${result.subStat || "Data tidak tersedia"}\n` +
        `*Passive Name:* ${result.passiveName || "Data tidak tersedia"}\n` +
        `*Passive Description:* ${result.passiveDescription || "Data tidak tersedia"}\n` +
        (result.refinement
          ? `\n*Refinement (${result.refinement.refine}):* ${result.refinement.description || "Data tidak tersedia"}\n`
          : "");
      m.reply(response);
    } else {
      throw new Error("Senjata tidak ditemukan.");
    }
  } catch (error) {
    console.error(error);
    let available = await genshindb.weapons("names", {
      matchCategories: true,
    });
    m.reply(
      `*Tidak Ditemukan*\n\n*Senjata yang tersedia:* ${available.join(", ")}`,
    );
  }
};
handler.help = ["giweapon <nama senjata>"];
handler.tags = ["genshin"];
handler.command = /^((gi|genshin)(weapons?|weapon))$/i;
handler.limit = true;
export default handler;
