Sheepolution
DIAdiscord.js - Imagine an app
•Created by Sheepolution on 11/27/2024 in #djs-questions
How to properly communicate between shards?
I tried something like this, but it ended up sending hundreds of messages when it should have sent one, or otherwise just crashing out. I can't seem to find a good guide or example on how to set up a way for one shard to communicate something to all shards.
4 replies
DIAdiscord.js - Imagine an app
•Created by Sheepolution on 12/4/2022 in #djs-questions
How to make sharding and caching work together?
* Today I added sharding
* I use a caching system for my bot
* My bot is used in both servers and DM.
Problem: If each shard uses its own caching, data will get desynced (e.g. a configuration is set to true in shard 0 but not in shard 1).
Solution: Only have one shard (shard 0) use caching.
Any suggestions on what would be the best approach to make this work? I'm asking because I'm not even sure I fully understand shards. From what I understand there is one client created by the shard manager that has shard 0. In that case I think I should do the following:
1. Check what shard its at.
2. In case of shard 0, do normal caching stuff.
3. Else, get the caching info from shard 0.
But then I'm not even sure how to have it check its at shard 0.
In any case, any tips on how to make this work would be appreciated.
10 replies