import genshindb from "genshin-db";
const handler = async (m, { conn, text, usedPrefix, command }) => {
  if (!text)
    throw `Contoh: *${usedPrefix + command} liyue*\nHarap berikan nama tempat.`;
  try {
    let result = await genshindb.geographies(text);
    if (result) {
      let response = `*Info Geografi: ${result.name}*\n\n`;
      response += `_${result.description}_\n\n`;
      response += `*Area:* ${result.area || "Data tidak tersedia"}\n`;
      response += `*Region:* ${result.region || "Data tidak tersedia"}\n`;
      response += `*Urutan Sortir:* ${result.sortorder || "Data tidak tersedia"}`;
      m.reply(response);
    } else {
      throw new Error("Geografi tidak ditemukan.");
    }
  } catch (error) {
    console.error(error);
    let available = await genshindb.geographies("names", {
      matchCategories: true,
    });
    m.reply(
      `*Tidak Ditemukan*\n\n*Geografi yang tersedia:* ${available.join(", ")}`,
    );
  }
};
handler.help = ["giarea <tempat>"];
handler.tags = ["genshin"];
handler.command = /^((gi|genshin)(areas?|geogra(fi|ph(y|ies?))))$/i;
handler.limit = true;
export default handler;
