import genshindb from "genshin-db";
const handler = async (m, { conn, text, args, usedPrefix, command }) => {
  if (!text)
    throw `Contoh: *${usedPrefix + command} temptation*\nHarap berikan nama makanan.`;
  try {
    let result = await genshindb.foods(text);
    if (result) {
      let response = `*Makanan Ditemukan: ${result.name}*\n\n`;
      response += `_"${result.description}"_\n\n`;
      response += `*Rarity:* ${result.rarity}\n`;
      response += `*Type:* ${result.foodtype}\n`;
      response += `*Category:* ${result.foodfilter} (${result.foodcategory})\n\n`;
      if (result.effect) {
        response += `*Effect:*\n${result.effect}\n\n`;
      }
      if (result.suspicious) {
        response += `*Suspicious:*\n${result.suspicious.effect}\n_"${result.suspicious.description}"_\n\n`;
      }
      if (result.normal) {
        response += `*Normal:*\n${result.normal.effect}\n_"${result.normal.description}"_\n\n`;
      }
      if (result.delicious) {
        response += `*Delicious:*\n${result.delicious.effect}\n_"${result.delicious.description}"_\n\n`;
      }
      m.reply(response);
    } else {
      throw new Error("Makanan tidak ditemukan.");
    }
  } catch (error) {
    console.error(error);
    let available = await genshindb.foods("names", {
      matchCategories: true,
    });
    m.reply(
      `*Tidak Ditemukan*\n\n*Makanan yang tersedia:* ${available.join(", ")}`,
    );
  }
};
handler.help = ["gifood <nama makanan>"];
handler.tags = ["genshin"];
handler.command = /^((gi|genshin)foods?)$/i;
handler.limit = true;
export default handler;
