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?
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.