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

149
Views
¿Cómo puedo llegar a un bot para responder a dms?

Entonces, trabajando con discordjs, me preguntaba si es posible que mi bot responda a los comandos enviados en dms con el bot. ¿Hay alguna manera de escuchar los DM? Ejemplo: ¿el usuario envía DM al bot con !test y el bot respondería en DM con éxito?

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

0

Luego, al configurar el new Discord.Client() , asegúrese de agregar el parcial "CHANNEL" y la intención DIRECT_MESSAGES ... También debe permitir esta intención en su portal de desarrolladores; de lo contrario, obtendrá un error de permisos de intenciones.

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

y luego en el messageCreate oyente, así es como escuchas un DM.

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

esto es verificar si el canal en el que se recibe el mensaje es un canal de mensajería directa, si no, regresará, de lo contrario, responderá con "¡Éxito!"

about 4 years ago · Juan Pablo Isaza Report

0

Podrías hacerlo

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

No estoy seguro, pero debería funcionar.

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!