Facebook
From Shuddho, 5 Months ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 131
  1. const axios = require('axios')
  2.  
  3. module.exports.config = {
  4.   name: 'ai',
  5.   version: '1.1.0',
  6.   hasPermssion: 0,
  7.   credits: 'emahid', // modified and created by emahid. API owner Emahid
  8.   description: 'AI Chatbot that can read images, answer your questions etc!',
  9.   usePrefix: false,
  10.   commandCategory: 'ai',
  11.   usages: ' [prompt]',
  12.   cooldowns: 0,
  13. }
  14.  
  15. module.exports.run = async function({ api, event, args }) {
  16.   const prompt = args.join(' ')
  17.   const credits = this.config.credits
  18.   const main = 'https://hazeyy-api-blackbox.kyrinwu.repl.co/ask?q='
  19.  
  20.  
  21.   if (!prompt) {
  22.     return api.sendMessage('Hello ? How can I help you today?', event.threadID, event.messageID)
  23.   }
  24.  else{
  25.     try {
  26.  
  27.         let url = main + prompt
  28.         //console.log(url)
  29.         let result = await axios.get(url)
  30.         //console.log(result)
  31.         let response = result.data.message
  32.         console.log(response)
  33.  
  34.         await api.sendMessage(response, event.threadID, event.messageID)
  35.       }
  36.       catch (error) {
  37.         console.log(error)
  38.         api.sendMessage('Unfortunately an error occured! Please try again later', event.threadID, event.messageID)
  39.       }
  40.  }
  41. }