// GOOGLE CMD const axios = require("axios"); const { cmd } = require("../command"); cmd({ pattern: "google", alias: ["gsearch", "search"], desc: "Search Google for a query.", category: "tools", react: "🌐", filename: __filename }, async (conn, mek, m, { args, reply }) => { try { // VĂ©rifiez si un mot-clĂ© est fourni if (args.length === 0) { return reply(`❗ *Please provide a search query.*\n\n*Example:*\n.google SubZero Md Bot`); } const query = args.join(" "); const apiKey = "AIzaSyDMbI3nvmQUrfjoCJYLS69Lej1hSXQjnWI"; // Votre clĂ© API Google const cx = "baf9bdb0c631236e5"; // Votre ID de moteur de recherche personnalisĂ© const apiUrl = `https://www.googleapis.com/customsearch/v1?q=${encodeURIComponent(query)}&key=${apiKey}&cx=${cx}`; // Appel API const response = await axios.get(apiUrl); // VĂ©rifiez si l'API a renvoyĂ© des rĂ©sultats if (response.status !== 200 || !response.data.items || response.data.items.length === 0) { return reply(`❌ *No results found for:* ${query}`); } // Format et envoi des rĂ©sultats let results = `🔎 *Google Search Results for:* "${query}"\n\n`; response.data.items.slice(0, 5).forEach((item, index) => { results += `*${index + 1}. ${item.title}*\n${item.link}\n${item.snippet}\n\n`; }); reply(results.trim()); } catch (error) { console.error(error); reply(`⚠ *An error occurred while fetching search results.*\n\n${error.message}`); } });