I am making a kick command for my bot, and it works well, but I also wanted it to DM the person who was kicked. I have mentioned member to mean the person you intend to ban, and this is my code after they are kicked:
msg.mentionedMember.send(‘You were kicked from ${guild.name} ${reason ? ‘for **${reason}**’ : ‘’}’);
When I run this, it says “Cannot read property 'send' of undefined”
What should I correct about this?
Do you have mentionedMember defined? if not, do:
var mentionedMember = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0]);
Then, all you need to do DM the mentioned user is:
mentionedMember.send(`You were kicked!`);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.