pixma
pixma

Reputation: 49

how can someone mention me and the bot says something, in discord js v12

So if people mention me, I want the bot to say "yo sup", I've used this code but the bot doesn't say anything I want the bot to say something back, I don't know what's wrong here

What should I fix in this code?

client.on("message", (message) => {
    if (message.author.bot) return;
   
    if (message.content.startsWith("<@myid> ")) {
        message.channel.send('yo sup');
    }; 
});

Upvotes: 1

Views: 174

Answers (1)

MrMythical
MrMythical

Reputation: 9041

You can use Message#mentions. Use the .users property from Message#mentions for this

if (message.mentions.users.has("your_id")) {
    message.channel.send('yo sup');
}

Upvotes: 3

Related Questions