Web Coder
Web Coder

Reputation: 11

I can't seem to figure out how to send a message to a specified user

The code I have is:

const sayMessage = args.join(" ");
message.delete().catch(O_o=>{}); 
message.author.send(sayMessage);

Instead of sending the message to the message author how do I make it send the message to a specified user?

Upvotes: 0

Views: 67

Answers (1)

Lucy Isabelle
Lucy Isabelle

Reputation: 98

To get the user that's tagged use

let member = message.mentions.members.first();
if(!member)
    return message.reply("Please tag a valid member");
member.send("Enter Message Here");

Note: Using let makes it only accessible in the scope its been declared, it may be smarter to use var in your case - You may also want to remove args[0] from the say message as it's going to be the mentioned member.

Upvotes: 2

Related Questions