【问题标题】:Error using discord bot on my ubuntu server在我的 ubuntu 服务器上使用不和谐机器人时出错
【发布时间】:2021-05-23 08:49:34
【问题描述】:

我有一个不和谐的机器人,在我的场所(Windows 10)它可以正常工作,但在服务器(Ubuntu Server 20)上它给了我以下错误。

当我收到来自服务器的聊天消息时发生错误,例如,在我的计算机上,我会阅读该消息并回复它,在服务器上,我收到错误。

(node:657201) UnhandledPromiseRejectionWarning: TypeError: (intermediate value).flatMap is not a function
    at Promise.all.events.map (/root/discordbot/node_modules/@typeit/src/logic/metadatas/MetadataStorage.ts:155:14)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:657201) 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(). (rejection id: 1)
(node:657201) [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.`

都是同一个项目,一切都一样,我不知道会发生什么。

【问题讨论】:

  • 您是否尝试使用 discord.js 发送嵌入式按摩?
  • Ubuntu机器上的Node版本是多少?基于this,你需要Node >= 11
  • 显示你的代码和node -v
  • @Owl 我有 v10.19.0
  • @Garto 是的,但我认为崩溃正在尝试读取消息

标签: javascript node.js typescript discord.js


【解决方案1】:

.flat().flatMap 仅在节点 >= 11 上可用

您好像使用的是 Node 10,请尝试将您的 Node 升级到版本 11+

你可以使用nvm,运行这个命令安装

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

然后运行nvm install node, 这将安装最新的节点版本,您也可以像这样指定版本 nvm install 12.16.3

然后使用版本,要使用最新版本,运行nvm use node 或使用特定安装版本,运行nvm install 12.16.3

然后通过运行node -v 验证您的节点版本

【讨论】:

    猜你喜欢
    • 2021-11-04
    • 1970-01-01
    • 2020-12-18
    • 2021-08-23
    • 2021-08-30
    • 2021-07-09
    • 2020-12-04
    • 2021-11-18
    • 2019-12-10
    相关资源
    最近更新 更多