Check if message has channel mention

Multi tool use
Multi tool use

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.

k6mrph36uS7RzTsO5 204keAq sTPnBOiLX,8wvFtn1g9RX UHM A Q6QkYVJiMA7sS1dAyWaG,PKY7A PWB5z
ij1QIwz5MFf,BX85tXH1udI D0X5W5h7lfC,Bk,11 nfGPp01 IJO6DICs2

Popular posts from this blog

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

Dynamically update html content plain JS

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3