【问题标题】:NPM UnhandledPromiseRejectionWarning [closed]NPM UnhandledPromiseRejectionWarning [关闭]
【发布时间】:2022-01-19 03:08:30
【问题描述】:

我在虚拟机和 AWS 上设置了 20.04 Ubuntu 服务器来运行不再由开发人员托管的 uno 机器人。 (https://github.com/Exium1/UnoBot) 我一直在按照某人的指南进行设置 (https://github.com/DaanWet/UnoBot/blob/master/documentation/Install.md),但是当我启动它时它失败了。

我收到以下错误:

(node:14998) UnhandledPromiseRejectionWarning: DiscordHTTPError: 401 Unauthorized on GET /api/v9/gateway/bot
    at RequestHandler.request (/home/ubuntu/UnoBot/node_modules/eris-sharder/node_modules/eris/lib/rest/RequestHandler.js:75:15)
    at Client.getBotGateway (/home/ubuntu/UnoBot/node_modules/eris-sharder/node_modules/eris/lib/Client.js:2135:36)
    at ClusterManager.calculateShards (/home/ubuntu/UnoBot/node_modules/eris-sharder/src/sharding/clustermanager.js:507:38)
    at process.nextTick (/home/ubuntu/UnoBot/node_modules/eris-sharder/src/sharding/clustermanager.js:179:41)
    at process._tickCallback (internal/process/next_tick.js:61:11)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
(node:14998) 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:14998) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js pro
cess with a non-zero exit code.

谁能帮忙解决这个问题?

【问题讨论】:

  • 问题不在于承诺拒绝没有得到处理。真正的问题是您收到来自服务器的 HTTP 401 Unauthorized 响应。您是否对此服务器进行了身份验证,以便您可以重试?
  • 这是一个不和谐的机器人,你在 config.js 文件中有一个令牌,所以我应该有身份验证
  • 权限问题?用合适的人重新邀请机器人。
  • 错误只是指一个无效的token 你需要添加一个有效的token here 并重命名为config.js

标签: mongodb npm discord discord.js


【解决方案1】:

为了解决记录的UnhandledPromiseRejectionWarning 警告,您可以通过在代码中添加以下内容来修复它:

process.on("unhandledRejection", console.error);

这将更清楚地记录错误,并防止您的控制台被这些警告填满。

至于@mmenschig 所说的,他们确实是正确的。确保您将正确的令牌传递到 <Client>.login()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-07
    • 1970-01-01
    • 2022-01-08
    • 2011-09-17
    • 2013-07-31
    • 2016-01-22
    • 1970-01-01
    相关资源
    最近更新 更多