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

341
Visualizações
discord.js Cannot read properties of undefined (reading 'send') after sending the message
Client.once('ready', () => {
    console.log('Bot online')
});

Client.on("message", message => {
    if (message.channel.id = '915302302682873909') {
        const logChannel = Client.channels.cache.find(channel => channel.id === "915302371519770664");
        //send author
        logChannel.send(`${message.author}` + ": ")
            .then(message => console.log(`Sent message: ${message.content}`));
        //send message content
        logChannel.send(message.content)
            .then(message => console.log(`Sent message: ${message.content}`));
    }
})

If I start up my bot and send a message to see if it works, it sends the `${message.author}` + ": " as it should but then immediately crashes saying TypeError: Cannot read properties of undefined (reading 'send') What's also really weird is that sometime (I couldn't figure out when) it sends both `${message.author}` + ": " and message.content before crashing.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This means that the logChannel is undefined.

If your id is correct, you could define it like this:

const logChannel = Client.channels.cache.get('915302371519770664') || Client.channels.fetch('915302371519770664');```
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