I'm not experienced in discord.js, but according to this in the documentation, a message object has a method message.isMemberMentioned(User or GuildMember)
. Using this method, one can use
client.on('message', message => { //this event is fired, whenever the bot sees a new message
if (message.isMemberMentioned(client.user)) { //we check, whether the bot is mentioned, client.user returns the user that the client is logged in as
//this is where you put what you want to do now
}
});
I would like to recommend, that you read the documentation fully, before you try to make a bot.
On v12 discord.js you now have to use message.mentions.has(bot.user)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…