Shard Broadcast
main.js
run.js
Use case of imported channels setup.js
Well as you know the server is getting cached on shard 1 idk why but it seems to always be the case. I fetch (cache.get) channels from that server for my bot to function but any other shard that doesn't share the same shard as the server with these channels can't fetch these channels on that other shard. I tried to use broadcast eval and other ways like saving channels in a seperate function in another file and initializing it from shard 1 but it always returned undefined on the other shards. I'm not sure either if im using broadcast eval correctly. I want to fix that but first i also want to know how is the main server we get the channels from allocated to shards? Can i get this server on which shard too and can i start shards before the others? I really need to fix this asap.
6 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!
- ✅
Marked as resolved by OPi provided code that handles only 1 shard being online. If you want me to provide my failed attempts i could try as well. But either way i need to find a solution.
Pretty sure that exporting from within an event listener isn't gonna work correctly. That being said, if you need to find a guild/channel on a shard to do something with like adding a follower, you need to use bEval and do the API request inside that function
i'll try that i still want to know based on what servers get allocated to which shards and if we can control this
:method: (static) ShardClientUtil#shardIdForGuildId()
[email protected]
Get the shard id for a given guild id.yeah im not going anywhere. i'm so confused. The slashcommand sends a request to it's specific shard so what i need this shard to request info from the main shard? I'm getting no where 💔
okay
I've got it thank you @Mark for your input i would have not figured it out. It's finally working.