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

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

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 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