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

150
Views
How can i get to a bot to respond to dms

So working with discordjs and was wondering if it is possible to have my bot respond to commands sent in dms with the bot is there a way to listen to DMs? Example: user DMs the bot with !test and the bot would respond in DMs with success?

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

0

Then when setting new Discord.Client() make sure to add the "CHANNEL" partial and the DIRECT_MESSAGES intent... You must also allow this intent in your developer portal else you will get an intents permissions error.

const client = new Discord.Client({
  partials: ["CHANNEL"],
  intents: [Discord.Intents.FLAGS.DIRECT_MESSAGES]
})

and then in the messageCreate listener this is how you listen for a DM.

if(command === "test" && message.channel.type === "DM"){
  message.channel.send("Success!")
}

this is checking if the channel the message is received in is a direct messaging channel, if not it'll return, else it will respond with with "Success!"

about 4 years ago · Juan Pablo Isaza Report

0

You could do

if(message.channel.DMChannel) {
   message.author.send("Success")
}

I am not sure but it should work.

about 4 years ago · Juan Pablo Isaza Report

0

if(message.channel.type == "DM"){ // if it's v12 just type change it to "dm"
// do sth

}
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!