const axios = require("axios"); module.exports = { config: { name: "chat", version: "1.1", author: "JARiF@Cock | Modified By NZ R ", category: "simSimi-bn", cooldown: 0, role: 0, guide: { en: "{p}chat hi\nfor deleting: {p}chat delete hi\nfor teaching: {p}chat teach hi | hello" } }, makeApiRequest: async function (question) { try { const response = await axios.get(`https://simsimi.vyturex.com/chat?ques=${encodeURIComponent(question)}`); return response.data; } catch (error) { throw error; } }, handleCommand: async function ({ args, message }) { try { const subCommand = args[0]; if (subCommand === 'teach') { const content = args.slice(1).join(" ").split("|").map((item) => item.trim()); if (content.length < 2) { return message.reply("Please provide both the question and the answer separated by '|'."); } const questi const answer = content.slice(1).join('|'); try { const teachUrl = `https://simsimi.vyturex.com/teach?ques=${encodeURIComponent(question)}&ans;=${encodeURIComponent(answer)}`; const teachResp axios.get(teachUrl); message.reply(teachResponse.data); } catch (error) { console.error(error); message.reply("Try again later dear."); } } else if (subCommand === 'delete') { try { const questi '); if (!questionToDelete) { message.reply('Please provide the question you want to delete.'); return; } const deleteUrl = `https://simsimi.vyturex.com/delete?ques=${encodeURIComponent(questionToDelete)}`; const deleteResp axios.get(deleteUrl); message.reply(deleteResponse.data); } catch (error) { console.error(error); message.reply(error.message); } } else { const name = args.join(' '); try { const result = await this.makeApiRequest(name); message.reply(result, (err, info) => { global.GoatBot.onReply.set(info.messageID, { commandName: this.config.name, messageID: info.messageID, author: message.senderID }); }); } catch (error) { console.error(error); message.reply('Oops! An error occurred.'); } } } catch (error) { message.reply('Oops! An error occurred: ' + error.message); } }, onStart: function ({ args, message }) { return this.handleCommand({ args, message }); }, onReply: function ({ args, message }) { return this.handleCommand({ args, message }); } };