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

171
Visualizações
Attempting to get message pin audit logs on discord.js does not return the log for the most recently pinned message

So I am trying to get my bot to log message pins and unpins. This code used to work until recently but now for some reason, the fetched logs do not have an entry for the message whose pinning triggered the messageUpdate event.

const fetchedLogs = await oldMessage.guild.fetchAuditLogs({
      type: 'MESSAGE_PIN',
    });
const pinLog = fetchedLogs.entries.filter(f => f.extra.messageID == oldMessage.id).first();
const { executor } = pinLog;

The error shown is:

Uncaught Promise Rejection TypeError: Cannot destructure property 'executor' of 'pinLog' as it is undefined.

This exact code used to work until recently.

Things I have tried:

  1. Attempted to make the code sleep for a bit (up to 10 seconds) before fetching the logs. Did not work
  2. Attempted to put the fetch into a loop until pinLog is not undefined anymore. Resulted in an infinite loop.
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As of v13, the naming for id properties have been changed (as shown in guide). Instead of .xxxID, it's now .xxxId

// messageID -> messageId
const pinLog = fetchedLogs.entries.filter(f => f.extra.messageId == oldMessage.id).first()

Also note, .find() would be more suited for this, since it gets the first object matching the callback

const pinLog = fetchedLogs.entries.find(f => f.extra.messageId == oldMessage.id)
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