分片时启动代码时出现 UnhandledPromiseRejectionWarning

UnhandledPromiseRejectionWarning while starting code while sharding

我正在尝试 运行 我的 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');

可以将spawnTimeout设置为-1Infinity以防止以后出现错误: https://discord.js.org/#/docs/main/stable/class/ShardingManager?scrollTo=spawn。如果您在将侦听器附加到 shardCreate 事件之前调用 ShardingManager#spawn,这也会发生这种情况,这可能会产生竞争条件,可能会阻止分片 0 执行成功启动。