简体   繁体   中英

Why is my Discord Bot is not responding when I mention it

Hi I am making it so when I ping the bot exactly it message something but when I do "@Wide#9236" It does not respond with anything. It worked a week ago but now it does not work suddenly.

I am using Discord.JS v12.5.1

Here is my code:

bot.on("message", message => {
    if (message.author.bot) return;
    if (message.channel.type === "dm") return
    
    if (message.content == bot.user.toString()) { 

        const embed = new Discord.MessageEmbed()
        .setTitle("Prefix")
        .setDescription('My Prefix is "!"')
        .setFooter('Type !help for more information')
        .setThumbnail(bot.user.displayAvatarURL())
        .setColor('RANDOM')
        message.channel.send(embed)
  
   }
  
  })

And I have no idea how to fix it as it worked a week ago.

You can detect if the bot was mentionned with message.mentions

if (message.mentions.has(client.user)) {
    if (message.mentions.everyone) return;
    // your stuff
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM