Need Help with Launching Multiple Shards Simultaneously in Discord.js

Hello everyone, I'm currently working on a relatively large bot that utilizes more than 200 shards. We're receiving a max_concurrency of 16 from Discord. Discord.js has been our go-to library from day one, and I can't express my gratitude enough to the developers and the community for making it incredibly easy to develop a bot. Lately, I've been experimenting with deploying multiple shards simultaneously. According to the Discord docs on Sharding, it should be possible. However, I've run into a bit of an issue. Despite my efforts, it seems like discord.js still waits approximately 5 seconds before initiating each shard, regardless of the delay being set to 0. Here's the code snippet I've been experimenting with:
async function startShards(group) {
// Start sharding
const mode = 'process';
const manager = new ShardingManager(bot, {
token: TOKEN,
shardList: group,
totalShards: totalShards,
mode: mode
});
manager.on('shardCreate', shard => console.log(`ShardManager: Shard ${shard.id} launched`));
await manager.spawn({delay: 0});
console.log(`Launched group: ${group}`);
}
async function startShards(group) {
// Start sharding
const mode = 'process';
const manager = new ShardingManager(bot, {
token: TOKEN,
shardList: group,
totalShards: totalShards,
mode: mode
});
manager.on('shardCreate', shard => console.log(`ShardManager: Shard ${shard.id} launched`));
await manager.spawn({delay: 0});
console.log(`Launched group: ${group}`);
}
An example value for group is [16,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]. Even with the delay set to 0, it seems the library is launching one shard at a time with an interval of around 5 seconds between each launch. I'm starting to wonder if there's an oversight on my part or a misuse of the ShardingManager. Any guidance or assistance on this matter would be highly appreciated. Thank you all for your continued support! Let me know if this is good to go, or if there are any changes you'd like me to make!
Discord Developer Portal
Discord Developer Portal ā€” API Docs for Bots and Developers
Integrate your service with Discord ā€” whether it's a bot or a game or whatever your wildest imagination can come up with.
3 Replies
d.js toolkit
d.js toolkitā€¢17mo ago
ā€¢ What's your exact discord.js npm list discord.js and node node -v version? ā€¢ Post the full error stack trace, not just the top part! ā€¢ Show your code! ā€¢ Explain what exactly your issue is. ā€¢ Not a discord.js issue? Check out #useful-servers.
nihilisticwhale
nihilisticwhaleā€¢17mo ago
I'm using [email protected] @Mod is there any way to get this question answered by a contributor to the library? Thanks so much!
monbrey
monbreyā€¢17mo ago
Not by pinging us I'm not an expert on sharding by any means but I'm pretty sure Discord imposes a rate limit of 5 seconds per identify, with each shard needing to identify to spin up. You cant have it at 0
Want results from more Discord servers?
Add your server