Facebook
From Fatin Rahman Jarif, 8 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 452
  1. const axios = require('axios');
  2. const stringSimilarity = require('string-similarity');
  3.  
  4. module.exports = {
  5.   config: {
  6.     name: 'chat',
  7.     version: '1.1',
  8.     author: 'JARiF',
  9.     category: "simSimi-bn",
  10.     cooldown: 0,
  11.     role: 0,
  12.     langs: {
  13.       en: {
  14.         noAnswerFound: "ki kos?",
  15.       }
  16.     }
  17.   },
  18.  
  19.   onStart: async function ({ api, args, message, event }) {
  20.     try {
  21.       const userQuestion = args.join(' ');
  22.       if (!userQuestion) {
  23.         message.reply(`You can't tell something?`);
  24.         return;
  25.       }
  26.  
  27.       const apiUrl = `https://simsimibn.syntax-team-co.repl.co/chat?ques=${encodeURIComponent(userQuestion)}`;
  28.       const response = await axios.get(apiUrl);
  29.       const botAnswer = response.data;
  30.  
  31.       if (!botAnswer) {
  32.         message.reply('What? :)');
  33.       } else {
  34.         message.reply(botAnswer);
  35.       }
  36.  
  37.     } catch (error) {
  38.       console.error('Error occurred:', error.message);
  39.       message.reply('An error occurred.');
  40.     }
  41.   }
  42. };
  43.