Code
const fetch = require("node-fetch");
client.on('messageCreate', async (message) => {
const chatbots = require("./All-Commands-Schemas/ChatbotSchema")
await chatbots.findOne({ guild: message.guild.id }, async (err, data) => {
if (!data) return;
if (err) throw err
const channell = data.channel
if (message.author.bot || message.channel.type === 'dm') return;
if (message.channel.id === channell) {
message.channel.sendTyping();
await fetch(`http://api.brainshop.ai/get?bid=161279&key=rhBjCAZC83zKEzYO&uid=${message.author.id}&msg=${message.content}`)
.then(response => response.json())
.then(data => {
message.channel.send(data.response);
})
.catch(() => {
message.channel.send("Couldn't fetch response!");
})
}
})
})
Versions
"node-fetch": "^2.6.1",
"discord.js": "^13.3.1",
"node": "16.13.2",
"npm": "8.1.2"
Error
NODE EVENT: Unhandled rejection: DiscordAPIError: Cannot send an empty message