Manual sharding
I'm just asking this for the sake of my curiosity. So I have parts of a discord bot that uses Discord.js. Each part performs something different, and instead of logging them into the same bot account, I'd like to shard them manually so they are responsible for operations done on certain guilds.
I'm aware sharding is not required if my bot's guild count does not reach the maximum limit. I asked this question just cause I'm curious to see if this is possible.
9 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!Look into child processes and workers in node.js
It is possible to distribute work to different threads/processes. This isn’t done nor handled by d.js tho
I'm aware that's a solution, however I was just asking if there was a way to manually spawn "shards" like that
No
If sharding like that is possible, then it also opens up the possibility to having a bot written in multiple languages
Ah, I see
Whichever shard a guild is assigned to is determined by a formula
Hmm, but what about the idea of a bot that's written in multiple languages?
Can you spawn a shard for the part that's written in JS for example, and then another shard for the other part that's written in Python?
D.js allows you to specify the shard ids you spawn
No idea abt d.py or any Python libs
Oh wait, ur just talking abt splitting up a process, not necessarily Discord sharding
I mean, you could have the python code relay messages to the js code via IPC
or vice-versa
Well, I could do that, but then both clients will be responsible for operations in all guilds, which means double responses to commands. But in case of shards, that doesn't happen. So I was just trying to find a way to shard a bot, but each shard (theoretically) can be written in a different language than others