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

204
Views
Obtengo [objeto Objeto] en lugar de salida

Entonces, tengo un comando que debería enviar un hecho aleatorio y traducirlo del inglés al ucraniano, pero en lugar de obtener un hecho aleatorio, solo muestra [object Object] . Aquí está mi código, estoy en discord.js v13.

 const { MessageEmbed } = require('discord.js'); const fetch = require('node-fetch'); const translate = require('@iamtraction/google-translate'); module.exports = { name: 'fact', description: 'Випадковий факт', category: 'Fun', async run({ interaction, bot }) { const response = await fetch('https://uselessfacts.jsph.pl/random.json?language=en'); await response.json().then(async res => { const translated = await translate(res, { to: 'uk' }); interaction.reply({ embeds: [new MessageEmbed().setTitle('Факт').setDescription(translated.text).setColor('RANDOM')] }); }); } };
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Es porque la API devuelve un objeto y lo convierte implícitamente en una cadena. Este objeto tiene una propiedad de text , por lo que debe usar await translate(res.text, { to: 'uk' }) .

Además, no debe mezclar then s con async/await. Solo elige uno:

 const { MessageEmbed } = require('discord.js'); const fetch = require('node-fetch'); const translate = require('@iamtraction/google-translate'); module.exports = { name: 'fact', description: 'Випадковий факт', category: 'Fun', async run({ interaction, bot }) { const response = await fetch( 'https://uselessfacts.jsph.pl/random.json?language=en', ); const { text } = await response.json(); const translated = await translate(text, { to: 'uk' }); interaction.reply({ embeds: [ new MessageEmbed() .setTitle('Факт') .setDescription(translated.text) .setColor('RANDOM'), ], }); }, };
about 4 years ago · Santiago Trujillo 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!