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

212
Views
I want my bot to send direct message to a user ONLY if the user's direct message

I am not making a command, i just want to send a message whenever a user dm's the bot. Any message. here's the code i wrote but it is specific for a command-

client.on("messageCreate", (message) => {
  if (message.content === "hi") {
    message.member.send("Hello")
  }
})
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

To execute a piece of code when a user DMs a bot, all you have to do is add the DIRECT_MESSAGES intent to your client. Then you can modify your current code to check if the message sent was in a DM and then execute a piece of code:

client.on("messageCreate", (message) => {
  if (message.channel.type === 'DM') {
    // Execute something
  }
})
about 4 years ago · Santiago Trujillo 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!