module.exports = { config: { name: "web", aliases: [], version: "1.0", author: "YourName", countDown: 5, role: 0, shortDescription: "Ask a question to different AI APIs.", longDescription: "This command allows you to ask a question to different AI APIs such as Hiro, Hercai, Black AI, or another AI API.", category: "Utility", guide: "/web - : Ask a question to the selected AI API.\n/web -list: Show all available AI APIs." }, onStart: async function ({ api, event, args }) { const baseURLs = { hiro: "https://hiro-api.replit.app/ai/hiro?content=", hercai: "https://hiro-api.replit.app/ai/hercai?content=", black: "https://hiro-api.replit.app/ai/black?content=", ai: "https://aiapiviafastapiwithimagebyjonellmagallanes.replit.app/ai?ask=" }; const options = Object.keys(baseURLs); if (args.length === 0 || args[0] === "-list") { api.sendMessage("Please specify an AI to use. Use '/web -list' to see available options.", event.threadID); return; } const selectedOption = args.shift().toLowerCase(); // Convert to lowercase for case-insensitive matching if (!options.includes(selectedOption)) { api.sendMessage("Invalid option. Use '/web -list' to see available options.", event.threadID); return; } const question = encodeURIComponent(args.join(" ")); const url = baseURLs[selectedOption] + question; try { // Sending "thinking" message await api.sendMessage(`${selectedOption} is thinking...`, event.threadID); // Making request to the selected API const response = await fetch(url); const data = await response.json(); // Handle the response data if (data.answer) { await api.sendMessage(data.answer, event.threadID); } else { await api.sendMessage("No answer received.", event.threadID); } } catch (error) { console.error("Error fetching data from API:", error); await api.sendMessage("An error occurred while fetching data from the API.", event.threadID); } } };