Check if message has channel mention

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Check if message has channel mention



I don't know what method to use to check if the message contains a mention to a channel; if it does, I want to continue with the execution, if not, return an error message.


if (message.mentions.channels == true)
console.log('Yeah, you used a channel mention');
else
console.log('Hey boy, you have to use a channel mention');



Can someone clear my doubt?




1 Answer
1



You can use Collection.first() to see if the collection has at least 1 element (that means that the message has at least 1 channel mention).

It should look like this:


Collection.first()


if (message.mentions.channels.first()) console.log("You used a channel mention.");
else console.log("You didn't.");





It worked fine. Thanks!
– danielperales555
Aug 16 at 0:06






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS