【问题标题】:message.content is not a functionmessage.content 不是函数
【发布时间】:2020-09-24 00:57:37
【问题描述】:

我正在创建一个不和谐的机器人。在我的message 事件中,我使用message.content.toLowerCase() 将消息文本与另一个字符串进行比较。但是,它给了我这个错误:

TypeError: message.content.toLowerCase is not a function

我也试过message.content,结果给了我:

TypeError: message.content is not a function

我的代码:

client.on('message', (message) => {
 if (message.content('ping')) {
  message.send('pong');
 }
});

【问题讨论】:

  • 并且,所有其他命令也停止工作并出现相同的错误
  • 尝试在事件中记录message,看看会发生什么
  • 怎么样?,抱歉我是新手
  • 我强烈建议先学习 Javascript,然后再学习
  • :(((((((((((((((((((((((((((((((((((())))

标签: javascript node.js discord discord.js


【解决方案1】:

message.content 不是函数。 contentmessage 对象的一个​​属性,它返回消息中的文本。我相信您正在寻找=== 运算符。

if(message.content === 'ping')

请阅读this guide 了解比较和逻辑运算符。

【讨论】:

    猜你喜欢
    • 2023-02-15
    • 2022-12-10
    • 1970-01-01
    • 2018-08-13
    • 2019-07-14
    • 2022-12-09
    • 2021-03-29
    • 1970-01-01
    • 2021-10-16
    相关资源
    最近更新 更多