import genshindb from "genshin-db";
const handler = async (m, { conn, text, usedPrefix, command }) => {
  if (!text)
    throw `Contoh: *${usedPrefix + command} outrider*\nHarap berikan nama kostum atau outfit.`;
  try {
    let result = await genshindb.outfits(text);
    if (result) {
      let response = `*Kostum Ditemukan: ${result.name}*\n\n`;
      response += `_${result.description || "Deskripsi tidak tersedia"}_\n\n`;
      response += `*Karakter:* ${result.character || "Data tidak tersedia"}`;
      if (result.url && result.url.modelviewer) {
        response += `\n_${result.url.modelviewer}_`;
      }
      m.reply(response);
    } else {
      throw new Error(`Kostum '${text}' tidak ditemukan.`);
    }
  } catch (error) {
    console.error(error);
    try {
      let availableOutfits = await genshindb.outfits(text, {
        matchCategories: true,
      });
      m.reply(`*List ${text} outfit :*\n\n- ${availableOutfits.join("\n- ")}`);
    } catch (error) {
      console.error(error);
      let availableOutfits = await genshindb.outfits("names", {
        matchCategories: true,
      });
      m.reply(
        `*Not Found*\n\n*Available outfits is:*\n${availableOutfits.join(", ")}`,
      );
    }
  }
};
handler.help = ["gioutfit <item>"];
handler.tags = ["genshin"];
handler.command = /^((gi|genshin)(costumes?|outfits?))$/i;
handler.limit = true;
export default handler;
