Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
DM Command wont DM users

Here is my code, when I run the command it won't send the message. I have the command handler set up correctly

const fs = require('fs');
module.exports = {
  name: 'accept',
  description: 'Accept',
  execute(message, args) {
    mentiondm = message.mentions.users.first();
    message.channel.bulkDelete(1);
    if (!message.member.roles.cache.some((role) => role.name === 'Owner'))
      return message.channel.send('Beep Boing: This command is way too powerful for you to use!');
    if (mentiondm == null) return message.reply('Beep Boing: No user to send message to!');
    mentionMessage = message.content.slice(3);
    mentiondm.send(mentionMessage);
    console.log('Message Sent!');
  },
};

This won't DM the user or respond in any way. Any ideas?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

First of all, mentiondm won't be null if no user is specified, instead it will return undefined. So instead of doing if (mentiondm == null), you could do if (!mentiondm) and so on.

Try checking for errors in your console as well. If an error pops up saying Cannot send message to this user, that means that the user has their DMs blocked, so you should catch the promise. For example, mentiondm.send("Some content").catch(e => { console.log(e.message) })

Another reason the bot is not sending messages could be that it does not have permissions to delete messages (message.channel.bulkDelete(1)). This would usually throw an error saying Missing Permissions or something like that. Also instead of deleting messages that way, you can just do message.delete() (if the bot has the permissions) which acts like the same way.

If no errors pop up, it could be that your function parameters are in the wrong order. Let's say in your main file, you did execute(client, message, args), here, message would be client and args will be message. So make sure that they are in order.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda