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

195
Views
(discord.js) TypeError: Cannot read property 'send' of undefined when trying to send a direct message

I have two text files, one with discord usernames with #, and another with the same amount of unique urls. I'm trying to make a discord bot to send each person one of the unique urls. I have run into an issue trying to send a test dm to one person. I keep getting the error.

TypeError: Cannot read property 'send' of undefined

    // Require the necessary discord.js classes
    const { Client, Intents } = require('discord.js');
    const { token } = require('./config.json');

    // Create a new client instance
    const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

    // When the client is ready, run this code (only once)
    client.once('ready', () => {
        console.log('Ready');
        client.users.cache.get('877248726085828720').send('yo');
    });

    // Login to Discord with your client's token
    client.login(token);

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Soo at the begining I think that you lose one intend so search them in API Documentation Discord.js Second I don't really understand where yiu want to send message but it should look like this

client.channels.cache.get('idhere').send('message');

I hope that helps you. Give me feedback if it does.

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!