// code from goatstore // api: https://store.agi.bd const fetch = require('node-fetch'); module.exports = { config: { name: "aninfo", version: "1.0", author: "Redwan", cooldown: 5, role: 0, shortDescription: "Search for anime info", longDescription: "Search for an anime and get detailed information.", category: "Anime", guide: "{p}anime " }, onStart: async function ({ event, api, args }) { if (!args.length) { return api.sendMessage("š™‹š™”š™šš™–š™Øš™š š™šš™£š™©š™šš™§ š™–š™£ š™–š™£š™žš™¢š™š š™£š™–š™¢š™š š™©š™¤ š™Øš™šš™–š™§š™˜š™.", event.threadID, event.messageID); } const query = encodeURIComponent(args.join(" ")); const searchUrl = `65.109.80.126:20511/api/animesearch?query=${query}`; try { const res = await fetch(searchUrl); if (!res.ok) { console.error("Failed to fetch anime data. HTTP Status: ", res.status); return api.sendMessage("š™€š™§š™§š™¤š™§ š™›š™šš™©š™˜š™š™žš™£š™œ š™–š™£š™žš™¢š™š š™™š™–š™©š™–.", event.threadID, event.messageID); } const data = await res.json(); if (!data || data.length === 0) { return api.sendMessage("š™‰š™¤ š™§š™šš™Øš™Ŗš™”š™©š™Ø š™›š™¤š™Ŗš™£š™™.", event.threadID, event.messageID); } const selectedAnimes = data.slice(0, 10); let msg = "š™Žš™šš™”š™šš™˜š™© š™–š™£ š™–š™£š™žš™¢š™š š™—š™® š™§š™šš™„š™”š™®š™žš™£š™œ š™¬š™žš™©š™ š™©š™š™š š™£š™Ŗš™¢š™—š™šš™§:\n"; selectedAnimes.forEach((anime, index) => { msg += `${index + 1}. ${anime.title} (⭐ ${anime.score})\nšŸ“ŗ š™š™®š™„š™š: ${anime.type} | šŸ”¢ š™€š™„š™žš™Øš™¤š™™š™šš™Ø: ${anime.episodes}\nšŸ“– š˜æš™šš™Øš™˜š™§š™žš™„š™©š™žš™¤š™£: ${anime.description}\n\n`; }); api.sendMessage(msg, event.threadID, (err, info) => { global.GoatBot.onReply.set(info.messageID, { commandName: "aninfo", messageID: info.messageID, author: event.senderID, animeList: selectedAnimes }); }); } catch (error) { console.error("Error fetching anime data: ", error); api.sendMessage("š™€š™§š™§š™¤š™§ š™›š™šš™©š™˜š™š™žš™£š™œ š™–š™£š™žš™¢š™š š™™š™–š™©š™–.", event.threadID, event.messageID); } }, onReply: async function ({ event, api, Reply }) { const { author, animeList, messageID } = Reply; if (event.senderID !== author) return; const choice = parseInt(event.body); if (isNaN(choice) || choice < 1 || choice > animeList.length) { return api.sendMessage("š™„š™£š™«š™–š™”š™žš™™ š™Øš™šš™”š™šš™˜š™©š™žš™¤š™£. š™‹š™”š™šš™–š™Øš™š š™šš™£š™©š™šš™§ š™– š™«š™–š™”š™žš™™ š™£š™Ŗš™¢š™—š™šš™§.", event.threadID, event.messageID); } const selectedAnime = animeList[choice - 1]; const infoUrl = `65.109.80.126:20511/api/animeinfo?url=${encodeURIComponent(selectedAnime.link)}`; try { const res = await fetch(infoUrl); if (!res.ok) { console.error("Failed to fetch anime details. HTTP Status: ", res.status); return api.sendMessage("š™€š™§š™§š™¤š™§ š™›š™šš™©š™˜š™š™žš™£š™œ š™–š™£š™žš™¢š™š š™™š™šš™©š™–š™žš™”š™Ø.", event.threadID, event.messageID); } const info = await res.json(); let details = `šŸŽ¬ **š™š™žš™©š™”š™š**: ${info.title}\n`; details += `šŸ“Œ **š˜¼š™”š™©š™šš™§š™£š™–š™©š™žš™«š™š š™š™žš™©š™”š™šš™Ø**:\n- š™€š™£š™œš™”š™žš™Øš™: ${info.alternativeTitles.english || "š™‰/š˜¼"}\n- š™…š™–š™„š™–š™£š™šš™Øš™š: ${info.alternativeTitles.japanese || "š™‰/š˜¼"}\n- š™Žš™®š™£š™¤š™£š™®š™¢š™Ø: ${info.alternativeTitles.synonyms || "š™‰/š˜¼"}\n\n`; details += `šŸ“– **š™Žš™®š™£š™¤š™„š™Øš™žš™Ø**: ${info.synopsis || "š™‰š™¤ š™Øš™®š™£š™¤š™„š™Øš™žš™Ø š™–š™«š™–š™žš™”š™–š™—š™”š™š."}\n\n`; details += `šŸ“ŗ **š™š™®š™„š™š**: ${info.information.type}\n`; details += `šŸ”¢ **š™€š™„š™žš™Øš™¤š™™š™šš™Ø**: ${info.information.episodes}\n`; details += `šŸ“… **š˜¼š™žš™§š™šš™™**: ${info.information.aired}\n`; details += `šŸŽ­ **š™‚š™šš™£š™§š™šš™Ø**: ${info.information.genres || "š™‰š™¤š™£š™š"}\n`; details += `šŸ·ļø **š˜æš™šš™¢š™¤š™œš™§š™–š™„š™š™žš™˜**: ${info.information.demographic || "š™‰š™¤š™£š™š"}\n`; details += `ā³ **š˜æš™Ŗš™§š™–š™©š™žš™¤š™£**: ${info.information.duration}\n`; details += `šŸ“‘ **š™Žš™¤š™Ŗš™§š™˜š™š**: ${info.information.source}\n`; details += `āš ļø **š™š™–š™©š™žš™£š™œ**: ${info.information.rating}\n`; details += `⭐ **š™Žš™˜š™¤š™§š™š**: ${info.statistics.score} | šŸ“Š **š™‹š™¤š™„š™Ŗš™”š™–š™§š™žš™©š™®**: #${info.statistics.popularity} | šŸ‘„ **š™ˆš™šš™¢š™—š™šš™§š™Ø**: ${info.statistics.members}\n`; details += `ā¤ļø **š™š™–š™«š™¤š™§š™žš™©š™šš™Ø**: ${info.statistics.favorites}\n`; if (info.externalLinks.length > 0) { details += "šŸ”— **š™€š™­š™©š™šš™§š™£š™–š™” š™‡š™žš™£š™ š™Ø**:\n"; info.externalLinks.forEach(link => { details += `- [${link.name}](${link.url})\n`; }); details += "\n"; } details += `šŸ”— [š™ˆš™¤š™§š™š š™„š™£š™›š™¤](${info.link})\n`; api.unsendMessage(messageID); api.sendMessage({ body: details, attachment: await global.utils.getStreamFromURL(info.imageUrl) }, event.threadID, event.messageID); } catch (error) { console.error("Error fetching anime details: ", error); api.sendMessage("š™€š™§š™§š™¤š™§ š™›š™šš™©š™˜š™š™žš™£š™œ š™–š™£š™žš™¢š™š š™™š™šš™©š™–š™žš™”š™Ø.", event.threadID, event.messageID); } } };