Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
117
rated 0 times [  118] [ 1]  / answers: 1 / hits: 21195  / 6 Years ago, wed, december 26, 2018, 12:00:00

I want to mention the user that sent the command. I know my code style is weird, but I like the JavaScript like functions.



So this is what I've tried, it mentions the user using the arguments sent.
So for example, if you did !mention <user_id> it would mention the user. I want to auto-detect this from the user sent.



function pingFunction(arguments, receivedMessage) {
if (arguments > 0) {
receivedMessage.channel.send(<@ + arguments + >);
} else {
receivedMessage.channel.send(<@ + arguments + >);
}
}


Thanks in advance!


More From » discord.js

 Answers
16

The way to get id of the person who sent the message is message.author.id, or in your case, receivedMessage.author.id.



From there, you can replace receivedMessage.channel.send(<@ + arguments + >) receivedMessage.channel.send(<@ + message.author.id + >);


[#52873] Monday, December 17, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
beatrices

Total Points: 745
Total Questions: 103
Total Answers: 105

Location: Guam
Member since Tue, Nov 29, 2022
2 Years ago
;