Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda