Discord.js mentioning

FBILOLIGIRL picture FBILOLIGIRL · Jan 24, 2020 · Viewed 12.3k times · Source
client.on('message', message => {
     if (message.content === `L!hug`) {
        if (!message.mentions.users.size) {
            return message.reply('you need to tag a user in order to hug them!!');

            const taggeduser = message.mentions.users.first();
        }
        // message goes below!
         message.channel.send(userID + ` you just got a hug  https://tenor.com/view/anime-cuddle-cute-gif-12668750`);
    }
}); 

I have tried a few ideas and I am very new to this library of language (discord.js)

Answer

Cipher picture Cipher · Jan 24, 2020

You can use message.mentions.members.first()

client.on('message', message => {
     if (message.content.startsWith('L!hug')) { 
    let targetMember = message.mentions.members.first();
    if(!targetMember) return message.reply('you need to tag a user in order to hug them!!');
        // message goes below!
         message.channel.send(`<@${targetMember.user.id}> you just got a hug  https://tenor.com/view/anime-cuddle-cute-gif-12668750`);
    }
});