【问题标题】:Discord.JS bot on heroku [duplicate]heroku 上的 Discord.JS 机器人 [重复]
【发布时间】:2021-11-10 14:54:17
【问题描述】:

昨天我使用 Discord.JS 创建了一个 Discord 机器人,当我在本地使用我的机器人时它可以正常工作,但是在 Heroku 上托管它之后它不再工作并且机器人处于离线状态。 在 Heroku 日志中,我可以看到:

2021-09-15T13:39:08.604792+00:00 heroku[worker.1]: State changed from crashed to starting
2021-09-15T13:39:10.850210+00:00 heroku[worker.1]: Starting process with command `node index.js`
2021-09-15T13:39:11.455306+00:00 heroku[worker.1]: State changed from starting to up
2021-09-15T13:39:12.189682+00:00 heroku[worker.1]: Process exited with status 0
2021-09-15T13:39:12.264472+00:00 heroku[worker.1]: State changed from up to crashed
2021-09-15T13:39:12.039073+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: ReferenceError: AbortController is not defined
2021-09-15T13:39:12.039088+00:00 app[worker.1]:     at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:172:15)
2021-09-15T13:39:12.039088+00:00 app[worker.1]:     at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:176:19)
2021-09-15T13:39:12.039088+00:00 app[worker.1]:     at RequestHandler.push (/app/node_modules/discord.js/src/rest/RequestHandler.js:50:25)
2021-09-15T13:39:12.039089+00:00 app[worker.1]:     at async WebSocketManager.connect (/app/node_modules/discord.js/src/client/websocket/WebSocketManager.js:128:9)
2021-09-15T13:39:12.039089+00:00 app[worker.1]:     at async Client.login (/app/node_modules/discord.js/src/client/Client.js:245:7)
2021-09-15T13:39:12.039090+00:00 app[worker.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2021-09-15T13:39:12.039423+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
2021-09-15T13:39:12.039451+00:00 app[worker.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

我完全不知道该错误的原因是什么。 如果有人可以帮助我,我会很高兴

【问题讨论】:

    标签: javascript node.js heroku discord.js


    【解决方案1】:

    您的问题已在另一个问题中得到解答。 Answer by Nick Parsons。基本上,你必须改变你的节点版本。

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    • 感谢您的帮助。我在指定节点版本时遇到了问题,但我在 package.json 文件中通过添加 ``` "engines": { "node": "v16.9.1" }, ``` 对其进行了更改
    猜你喜欢
    • 2020-06-27
    • 1970-01-01
    • 2021-07-11
    • 2021-07-14
    • 2021-08-17
    • 2019-02-16
    • 1970-01-01
    • 2020-02-02
    • 2017-10-31
    相关资源
    最近更新 更多