【发布时间】:2021-07-21 18:24:52
【问题描述】:
我正在尝试运行我的 index.js 文件,该文件运行我的 bot.js 文件。当我做 node index.js 时,我得到了这个错误。 Index.js 正在分片我的 bot.js 文件 (discord.js)
(node:7284) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
at Shard.onDeath (C:\Users\Sochum\Desktop\BobloxBot\node_modules\discord.js\src\sharding\Shard.js:158:16)
at Object.onceWrapper (events.js:422:26)
at Shard.emit (events.js:315:20)
at Shard._handleExit (C:\Users\Sochum\Desktop\BobloxBot\node_modules\discord.js\src\sharding\Shard.js:384:10)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
(node:7284) 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: 7)
它实际上并没有说明错误是什么。这是我的 index.js 代码:
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', {
totalShards:4,
token: "#",
})
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
manager.spawn();
这是我的 bot.js 文件代码 https://pastebin.com/RW8abmKP
我不确定为什么会收到此错误,但它可能与以 bot.js 开头的代码有关
new EconomyClient().start(require(`./config`).token, './commands', './index');
【问题讨论】:
标签: javascript node.js discord.js sharding