import genshindb from "genshin-db";
const handler = async (m, { conn, text, usedPrefix, command }) => {
  if (!text)
    throw `Contoh: *${usedPrefix + command} squirrel fish*\nHarap berikan nama ramuan atau makanan.`;
  try {
    let result = await genshindb.foods(text);
    if (result) {
      let response = `*Ramuan atau Makanan Ditemukan: ${result.name}*\n\n`;
      response += `_${result.description || "Deskripsi tidak tersedia"}_\n\n`;
      response += `*Rarity:* ${result.rarity || "Data tidak tersedia"}\n`;
      response += `*Efek:* ${result.effect || "Data tidak tersedia"}`;
      m.reply(response);
    } else {
      throw new Error(`Ramuan atau makanan '${text}' tidak ditemukan.`);
    }
  } catch (error) {
    console.error(error);
    try {
      let availableFoods = await genshindb.foods("names", {
        matchCategories: true,
      });
      m.reply(`*List ${text} foods :*\n\n- ${availableFoods.join("\n- ")}`);
    } catch (error) {
      console.error(error);
      let availableFoods = await genshindb.foods("names", {
        matchCategories: true,
      });
      m.reply(
        `*Not Found*\n\n*Available foods is :*\n${availableFoods.join(", ")}`,
      );
    }
  }
};
handler.help = ["gipotion <nama ramuan>"];
handler.tags = ["genshin"];
handler.command = /^((gi|genshin)(potion|foods?))$/i;
handler.limit = true;
export default handler;
