Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
I'm making a chatbot translated into Portuguese but when the bot will send the answer instead of returning the translation it returns [object Object]

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();
  }
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Based on the packages documentation in npm the translate method returns Promise<Object> with text property. It means that if you want to get the text after translation then you must use it as: translat.text

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!