【问题标题】:If message.channel.type == "category" && message.channel.id == 'XXX' - is not working如果 message.channel.type == "category" && message.channel.id == 'XXX' - 不工作
【发布时间】:2020-03-21 06:57:49
【问题描述】:

大家晚上好, 我希望在发送消息时,机器人会检查消息是否在 X 类通道中发送。如果是,则应执行代码。

if(message.channel.type == "category" && message.channel.id == '656144179319013376'){
        //Code to be executed
    }

不幸的是,这不起作用。我还查看了文档,一无所获。请帮我! - 总结

【问题讨论】:

    标签: node.js discord.js


    【解决方案1】:

    我想这就是你要找的东西?当事件被调用时,消息作为参数传递,消息有一个称为通道的字段。这将返回实际频道,而不是类别。因此,您必须让频道的父频道检查它是否正确:)

    if (message.channel.parent !== undefined && message.channel.parent.id === "categoryIDhere") {
        // Code
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-28
      • 1970-01-01
      • 2015-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-21
      相关资源
      最近更新 更多