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

337
Vistas
discord.js DiscordAPIError: Unknown Message

I have array which I'm cycling through via reactions on an embed. When a reaction is pressed, the message should be deleted and the function loops again. At the second reaction press, I'm getting this error:

(node:12908) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message

At each reaction press after the first, the amount of this error printed is doubled.

Code:

function movieChoiceEmbed(movies, message, count)
{
    pagecount = count;

    message.channel.send({embed: {
        color: '#D733FF',
        title: 'Choose movie',
        fields: [
            {
                name: movies[pagecount].title,
                value: movies[pagecount].description,
                inline: true,
            },
            {
                name: movies[pagecount+1].title,
                value: movies[pagecount+1].description,
                inline: true,
            },
            {
                name: '\u200b',
                value: '\u200b',
                inline: false,
            },
            {
                name: movies[pagecount+2].title,
                value: movies[pagecount+2].description,
                inline: true,
            },
            {
                name: movies[pagecount+3].title,
                value: movies[pagecount+3].description,
                inline: true,
            },
        ],
        timestamp: new Date(),
        footer: {
            icon_url: client.user.displayAvatarURL(),
            text: 'Andrea Gafa'
        }
      }})
        .then(sentEmbed => {
            sentEmbed.react("⏪");
            sentEmbed.react("⏩");
        })
        .catch();

    client.on("messageReactionAdd", async (reaction, user) => { // When a reaction is added
        if(user.bot) return; 

        if(reaction.emoji.name == "⏪")
        {
            await reaction.message.delete();
            count -= 4;
            movieChoiceEmbed(movies, message, count);
        }else if(reaction.emoji.name == "⏩")
        {
            await reaction.message.delete();
            count += 4;
            movieChoiceEmbed(movies, message, count);
        }
        return;
    });
}

I have tried deleting the last message instead with the same result:

await message.channel.lastMessage.delete();

Any clue? I'm pretty lost here.

Edit:

The messagereactionadd event being inside the function seems to be the problem. Putting it outside it fixes the issue.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

your error is because you're getting a promise that isn't caught. You have several calls that are async and returning promises, one or more of them is causing an error. I would add catch blocks to them, and then this will help you isolate where your problem lies. For example:

await reaction.message.delete();

could be changed to:

await reaction.message.delete()
     .then(() { /* do something if interested */ })
     .catch(err => { console.error(err); });

add this to all your promised functions and you'll know where you're having issues.

Now as for the error itself, you're trying to delete a message, potentially, that has already been deleted. Did you want to delete a reaction, or a message? If you've deleted a message, and then try to do something with the message in the calls subsequently, then that's the problem.

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