Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

336
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!