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 toolkit11mo 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
Syjalo11mo ago
Yes, if you manually fetch the guild
Stqlth
StqlthOP11mo 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
Syjalo11mo 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
StqlthOP11mo ago
I mean is there any other way a guild, not assigned to the shard, to get into the shard's guild cache
Syjalo
Syjalo11mo 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
StqlthOP11mo 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
monbrey11mo ago
It shouldn't happen on its own, no
Stqlth
StqlthOP11mo 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
monbrey11mo 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
StqlthOP11mo ago
yea but on start up there would never be duplicates right?
monbrey
monbrey11mo ago
correct
Stqlth
StqlthOP11mo 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
StqlthOP11mo ago
No description
monbrey
monbrey11mo ago
The cache is already a map
Syjalo
Syjalo11mo ago
It's impossible, because they keyed by the id in the Collection.
monbrey
monbrey11mo ago
it wont have duplicates
Stqlth
StqlthOP11mo ago
I believe you guys but somehow in a for loop going through the guild cache I get duplicates:
No description
Stqlth
StqlthOP11mo ago
it makes no fucing sense
monbrey
monbrey11mo ago
how are you determining that
Stqlth
StqlthOP11mo 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
monbrey11mo 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
StqlthOP11mo 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
monbrey11mo 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
StqlthOP11mo 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