UNPKG

chatbotlouis

Version:

chat

18 lines (13 loc) 824 B
const fetch = require("node-fetch"); async function chatBot(options = {}) { if (!options.Message) throw new Error(`No Message Provided`); if (options.Message.length > 1900) throw new Error("Message Should Be Less Than 2000 Words"); if(!options.Message.content) throw new Error(`No Message Provided`); const res = await fetch(encodeURI(`https://api.affiliateplus.xyz/api/chatbot?message=${options.Message?.content}&botname=${options.Message?.client.user.username}&ownername=${options.Message?.author.tag}&user=${options.Message?.author.tag}`)), json = await res.json(); if (!json.message) throw new Error(`An Error Occured`); if (options.ResultOnly && options.ResultOnly === true) return { Result: json.message }; return json.message; }; module.exports = chatBot;