Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda