我正在使用node.js模块discord.js与Discord机器人合作。
最近,当使用工作wifi时,启动时会出现错误(当机器人尝试登录时),我认为它是通过某种方式配置的,导致其损坏。
(node:104) UnhandledPromiseRejectionWarning: FetchError: request to https://discordapp.com/api/v7/gateway/bot failed, reason: read ECONNRESET
at RequestHandler.execute (C:\Users\user\Desktop\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:106:9)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:104) 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:104) [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.
使用APIRequest的文件RequestHandler.js
抛出错误
文件APIRequest.js
中的方法make
从文件index.js
中返回函数fetch
的结果,文件req.on('error', function (err) { ... });
返回rejected promise。
变量req
是https模块的方法ClientRequest
的_http_client
(来自模块returned)request
。
如果我将events.js:167
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:111:27)
Emitted 'error' event at:
at TLSSocket.socketErrorListener (_http_client.js:391:9)
at TLSSocket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
注释掉,则会出现以下错误:
internal/stream_base_commons.js
我相信这是从here抛出的,但这是Node.js({"code": 0, "message": "401: Unauthorized"}
)的内部模块,我无法对其进行编辑并继续进行更深入的跟踪。必须编辑和重新编译,这是我不知道的方法。
当我去https://discordapp.com/api/v7/gateway/bot时,我得到了答复:
$cust_id=$_SESSION['cust_id'];
$stmt = $conn->prepare("SELECT tbl_item.* FROM tbl_cart, tbl_item WHERE tbl_cart.cust_id = :cust_id AND tbl_item.product_id = tbl_cart.product_id);
$stmt->bindParam('cust_id',$cust_id);
$stmt->execute();
$rows = $stmt->fetchAll();
foreach($rows as $row)
{
print_r($row);
}
我需要帮助来了解导致原始错误的确切原因,以及是否有任何解决方法来继续运行该机器人。
答案 0 :(得分:0)
我遇到了同样的问题,我刚刚检查了机器人登录令牌,但它已经过时了。尝试在Discord开发人员门户上生成新的机器人令牌!