Facebook
From ddd, 8 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 488
  1. const axios = require('axios');
  2.  
  3. module.exports.config = {
  4.     name: "chat",
  5.     version: "1.0.0",
  6.     hasPermssion: 0,
  7.     credits: "JARiF",
  8.     cooldowns: 5,
  9.     commandCategory: "heda",
  10.     usePrefix: true,
  11. };
  12.  
  13. module.exports.run = async function({ api, event, args }) {
  14.     try {
  15.         const userQuestion = args.join(' ');
  16.        
  17.         if (!userQuestion) {
  18.             return api.sendMessage(`You can't tell me something?`, event.threadID);
  19.         }
  20.  
  21.         const apiUrl = `https://simsimibn.syntax-team-co.repl.co/chat?ques=${encodeURIComponent(userQuestion)}`;
  22.         const response = await axios.get(apiUrl);
  23.         const botAnswer = response.data;
  24.  
  25.         if (!botAnswer) {
  26.             return api.sendMessage('What? :)', event.threadID);
  27.         } else {
  28.             return api.sendMessage(botAnswer, event.threadID);
  29.         }
  30.     } catch (error) {
  31.         console.error('Error occurred:', error.message);
  32.         return api.sendMessage('An error occurred.', event.threadID);
  33.     }
  34. };
  35.