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

189
Views
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 answers
Answer question

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