简体   繁体   English

分片在 Shard 0 Discordjs 上崩溃

[英]Sharding Crashing On Shard 0 Discordjs

I am trying to shard my discord bot in v13, and when I run just the main file (bot.js) on my beta bot without sharding, it works fine, but when I try running it with sharding, It gives this error.我试图在 v13 中对我的不和谐机器人进行分片,当我在我的 beta 机器人上运行主文件(bot.js)而不进行分片时,它工作正常,但是当我尝试使用分片运行它时,它给出了这个错误。

在此处输入图像描述

Here is the index.js code where I shard这是我在其中分片的 index.js 代码


const { ShardingManager } = require('discord.js');

const manager = new ShardingManager('./bot.js', { token: 'tokenhere' });

manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));

manager.spawn();

When I try running just bot.js without sharding, it gives the error that says too many guilds on one session, meaning the main file is fine.当我尝试在没有分片的情况下只运行 bot.js 时,它给出的错误是在一个会话中显示过多的公会,这意味着主文件很好。

Here is the main file code这是主文件代码

https://pastebin.com/8JNFxXqY https://pastebin.com/8JNFxXqY

I don't think there are any errors on this file.我认为这个文件没有任何错误。 Please let me know how to fix this, and how to shard properly请让我知道如何解决这个问题,以及如何正确分片

You are running node .您正在运行node . which if I am not mistaken starts all the .js files in the folder you are in.如果我没记错的话,它会启动您所在文件夹中的所有 .js 文件。

What happens is that both index.js and bot.js files are started.发生的情况是index.jsbot.js文件都已启动。

You must run ONLY the file where the ShardingManager is, with node index.js .您必须仅使用node index.js运行ShardingManager所在的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM