Reputation: 107
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?
Upvotes: 0
Views: 3877
Reputation: 6816
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:
if (message.mentions.channels.first()) console.log("You used a channel mention.");
else console.log("You didn't.");
Upvotes: 1