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

234
Vistas
Promise { <pending> } LOG

i was making meme.js file/command and i got this error idk how to resolve this problem, Can you help me?

so this is my code:

const fetch = require('node-fetch');
const randomPuppy = require("random-puppy");

module.exports = {
    name: "meme",
    description: "Sends an epic meme",
    execute(message) {
        const subReddits = ["dankmeme", "meme", "me_irl"];
        const random = subReddits[Math.floor(Math.random() * subReddits.length)];

        const img = await randomPuppy(random);
        console.log(img)
        const memeEmbed = new MessageEmbed()
            .setColor("#fa0557")
          //  .setImage(`${img}`)
            .setTitle(`From /r/${random}`)
            .setURL(`https://reddit.com/r/${random}`);

        message.channel.send({ embeds: [memeEmbed] });
    }
}

And this is the log i got:

Promise { <pending> }
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The posted code throws a syntax error that await can only be used inside an async function - which `module.exports.execute' has not been declared as.

Try declaring execute as an async function

module.exports = {
    name: "meme",
    description: "Sends an epic meme",
    async execute(message) { . . .

If the log in the post does show

Promise { <pending> }

on the console, please update the post with necessary code to reproduce the problem.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Your code as shown will not run. You show await randomPuppy(random), but await is NOT allowed there because it's not inside an async function. So, I suspect that your real code does not have the await and that's why you show Promise { <pending> } in your console. You have to use either await or .then() on the promise that randomPuppy(random) returns.

If I fix your code so that it will run by adding async to the execute() definition, then the console.log(img) actually works just fine:

const randomPuppy = require("random-puppy");

module.exports = {
    name: "meme",
    description: "Sends an epic meme",
    async execute(message) {
        const subReddits = ["dankmeme", "meme", "me_irl"];
        const random = subReddits[Math.floor(Math.random() * subReddits.length)];

        const img = await randomPuppy(random);
        console.log(img)
    }
}

module.exports.execute().then(result => {
    console.log(result);
}).catch(err => {
    console.log(err);
});

And, I get in my console this:

http://imgur.com/FFkL628.gif
done

So, my conclusion is that the code you posted in your question is not the code you're actually running. This code shown here will work just fine.

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