I want make my bot delete any tag that tag me, but it doesn’t work. It work successful in random word but failed in tag such as <@id>.
bot.on("message", message => {
if (message.content.startsWith("")) { //what should I write in ""?
message.delete()
}
})
>Solution :
Check if the bot was mentioned using Message#mentions.
if (message.mentions.users.has(bot.user.id)) {
message.delete()
}
Note that this also counts for replies that mention the user. If you want to check the message content, but not replies, you can use regex
const regex = new RegExp(`<@!?${bot.user.id}>`)
if (regex.test(message.content)) {
message.delete()
}