I'm making a chatbot and I'm trying to understand why it's returning [object Object], I'm trying to translate the answer o from en to pt.
client.on("message", async message => {
if (message.channel.name == "chatbot") /*name channel*/ {
if (message.author.bot) return;
message.content = message.content.replace(/@(everyone)/gi, "everyone").replace(/@(here)/gi, "here");
if (message.content.includes(`@`)) {
return message.channel.send(`**❌ Please dont mention anyone**`);
}
message.channel.startTyping();
if (!message.content) return
const translate = require("@iamtraction/google-translate"); //api
const translated = await translate(message.content, {
to: 'en'
}); //translating
/*message.channel.send("Please say something.");*/
fetch(`https://api.affiliateplus.xyz/api/chatbot?message=${encodeURIComponent(translated)}&botname=${client.user.username}&ownername=DEVELOPER_NAME`)
.then(res => res.json())
.then(async data => {
const translat = await translate(data.message, {
to: 'pt'
}); //translating
message.inlineReply(`${translat}`); //here is where it returns [object Object]
});
message.channel.stopTyping();
}
});