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

279
Views
Discordjs bot error what's my mistake? cannot read property 'send' of undefined

It seems that the code is normal, but it displays cannot read property send of undefined in the console, despite the fact that in the console output it is clearly defined. Args is registered in index.js

const Discord = require('discord.js');
const data = require('quick.db');
const settings = require('../settings.json')

exports.run = async(client, message, args) => { 
var rcv = args[0];
var msg = args.slice(1).join(' ');
var sender = message.author;
console.log(rcv + ' ' +msg)

client.users.cache.get(rcv).send(msg);


}

exports.help = {
  name: 'private',
  aliases: ['private', 'pmsg']
}

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

0

Did you try using fetch?

const user = await client.users.fetch(rcv);
user.send(msg);
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!