Can two shards have the same guild in the guild cache?
This may seem like a dumb question, but it's genuine; I believe I am having a scenario where two shards have the same guild. ping on reply
25 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!Yes, if you manually fetch the guild
interesting, is there any other way? (I ask because I don't believe I am doing that, but I will double check to confirm)
A way to get a guild?
I don't think you can get the guild in your main process, but you can do whatever you want in broadcast eval
I mean is there any other way a guild, not assigned to the shard, to get into the shard's guild cache
I'm not sure if fetch is good there. There's cache option to prevent caching new fetched structures. I'd prefer to use broadcast eval.
I might not be explaining my question right. Basically, I have a situation where two shards have the same guild (I don't want this) and I am not sure how it happened
I don't really ever fetch specific guilds
It shouldn't happen on its own, no
Hmm, I am going to keep investigating and follow up here. If there is a bug causing this it could be specific to big bots
can duplicates exist in the cache?
Of one shard? no
Well, unless you managed to manually store an entire guild object under the wrong id but that would mess up so much more
yea but on start up there would never be duplicates right?
correct
welp, I don't know what the else could be causing my issue so I am going to add some logging to ensure this isn't the case (this is from a job that runs when the bot finishes logging in):
The cache is already a map
It's impossible, because they keyed by the id in the Collection.
it wont have duplicates
I believe you guys but somehow in a for loop going through the guild cache I get duplicates:
it makes no fucing sense
how are you determining that
simple logging, I do an action on every guild in the cache, in the most recent case, it was sending a message, had multiple reports of duplicate messages, one of my test servers also had a duplicate message, took the server ids and searched the logs, 77 servers out of about 73k that were processed has duplicate ids in the logs
Well, I dont see how thats possible without cache manipulation, as Map keys are unique
And we just assign the guilds to shards as Discord tells us to
Hypothetically, if discord was fucking up, could that cause it?
iirc maps can't have duplicate keys but can have duplicate values
this would actually make more sense since one of my servers had two messages, sent to two different channels, yet the logic to determine which channel I use is always the same. So if a map had two values for the guild, it could cause two different logic paths when getting the channel
not sure if that made sense but oh well
but that still wouldn't explain why the loop was letting it happen more than once, since it is by key nvm I loop through the values
It would have to be a very very major fuckup since we key them by guild id
If anything in the cache has a different guild.id on the value to its key, I'd point to your code before ours or Discord
added a bunch of logging to get some more information, I'll have time to restart one of my clusters tomorrow and I'll update what the logs show