检查消息是否提及频道
Check if message has channel mention
我不知道用什么方法来检查消息是否包含对频道的提及;如果是,我想继续执行,如果不是,return 一条错误消息。
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');
}
谁能解开我的疑惑?
您可以使用 Collection.first()
查看该集合是否至少有 1 个元素(这意味着该消息至少有 1 个频道提及)。
它应该是这样的:
if (message.mentions.channels.first()) console.log("You used a channel mention.");
else console.log("You didn't.");
我不知道用什么方法来检查消息是否包含对频道的提及;如果是,我想继续执行,如果不是,return 一条错误消息。
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');
}
谁能解开我的疑惑?
您可以使用 Collection.first()
查看该集合是否至少有 1 个元素(这意味着该消息至少有 1 个频道提及)。
它应该是这样的:
if (message.mentions.channels.first()) console.log("You used a channel mention.");
else console.log("You didn't.");