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
d.js toolkit
d.js toolkit10mo ago
- 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!
Syjalo
Syjalo10mo ago
Yes, if you manually fetch the guild
Stqlth
StqlthOP10mo ago
interesting, is there any other way? (I ask because I don't believe I am doing that, but I will double check to confirm)
Syjalo
Syjalo10mo ago
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
Stqlth
StqlthOP10mo ago
I mean is there any other way a guild, not assigned to the shard, to get into the shard's guild cache
Syjalo
Syjalo10mo ago
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.
Stqlth
StqlthOP10mo ago
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
monbrey
monbrey10mo ago
It shouldn't happen on its own, no
Stqlth
StqlthOP10mo ago
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?
monbrey
monbrey10mo ago
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
Stqlth
StqlthOP10mo ago
yea but on start up there would never be duplicates right?
monbrey
monbrey10mo ago
correct
Stqlth
StqlthOP10mo ago
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):
Stqlth
StqlthOP10mo ago
No description
monbrey
monbrey10mo ago
The cache is already a map
Syjalo
Syjalo10mo ago
It's impossible, because they keyed by the id in the Collection.
monbrey
monbrey10mo ago
it wont have duplicates
Stqlth
StqlthOP10mo ago
I believe you guys but somehow in a for loop going through the guild cache I get duplicates:
No description
Stqlth
StqlthOP10mo ago
it makes no fucing sense
monbrey
monbrey10mo ago
how are you determining that
Stqlth
StqlthOP10mo ago
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
monbrey
monbrey10mo ago
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
Stqlth
StqlthOP10mo ago
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
monbrey
monbrey10mo ago
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
Stqlth
StqlthOP10mo ago
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
Want results from more Discord servers?
Add your server