【问题标题】:Check if message has channel mention检查消息是否有频道提及
【发布时间】:2018-08-13 01:26:16
【问题描述】:

我不知道使用什么方法来检查消息是否包含对频道的提及;如果是,我想继续执行,如果不是,返回错误信息。

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');
}

有人能解开我的疑惑吗?

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    您可以使用Collection.first() 查看该集合是否至少有 1 个元素(这意味着该消息至少有 1 个频道提及)。
    它应该是这样的:

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

    【讨论】:

      猜你喜欢
      • 2021-09-26
      • 1970-01-01
      • 2021-09-18
      • 2023-03-11
      • 2019-05-31
      • 1970-01-01
      • 2021-04-13
      • 2021-07-14
      • 2020-10-13
      相关资源
      最近更新 更多