首页 > 解决方案 > 在heroku中运行时命令处理程序不起作用

问题描述

discord js 的命令处理程序在 Heroku 中运行时不起作用,但在本地运行时起作用。收到的大多数错误是由于程序无法识别模块

示例命令:

module.exports = {
  name: '8ball',
  description: '8ball',
  execute(receivedMessage, args) {
    if (args.length == 0) return
    receivedMessage.channel.send(response.ball())
  }
}

上述命令错误:

2020-10-25T13:04:07.355215+00:00 app[web.1]: receivedMessage.channel.send(response.ball())
2020-10-25T13:04:07.355216+00:00 app[web.1]:                              ^
2020-10-25T13:04:07.355216+00:00 app[web.1]: 
2020-10-25T13:04:07.355217+00:00 app[web.1]: ReferenceError: response is not defined

在上面的代码中,'response' 是一个自定义模块。虽然在使用 discord API 模块时会引发相同的错误。

标签: node.jsherokudiscord.js

解决方案


推荐阅读