I am implementing a command to mute users. For example, the following command would mute the user @anon for 5 seconds:
!mute @anon 5
My program listens for the message event, mutes the user and sends a confirmation message like this:
@anon#1234 has now been muted for 5 s
Unfortunately Discord does not recognize the username in this message as a mention. How can I mention a specific user with the msg.channel.send function? This sample includes the code which sends the confirmation message:
bot.on("message", msg => {
let args = msg.content.substring(PREFIX.length).split(" ")
let time = args[2]
let person = msg.guild.member(msg.mentions.users.first() || msg.guild.members.fetch(args[1]))
// muting the user here and sending confirmation message
msg.channel.send(`@${person.user.tag} has now been muted for ${time} s`)
setTimeout(() => {
// unmuting the user after specified time and
// sending confirmation message
msg.channel.send(`@${person.user.tag} has been unmuted.`)
}, time * 1000);
})
The muting is not included in this sample, it works. The messages are being sent correctly but the user is not mentioned, meaning the username is not clickable and doesn't get highlighted.