Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda