Preventing some guilds from being cached
I want to customize my cache to prevent my Bot from caching the GuildMembers of any guild which isn't set up in my database, because without being setup, the bot really can't do anything for the server. and I would like to save memory
I have a list of ids I don't want cached when my bot starts up, and I was thinking of using sweepers to achieve this, is this the correct route to take?
Additionally, can I alter the sweeper while the bot is running to add servers to the cache?
12 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.Please ping on reply
well im not sure how to do this efficiently
but the first thing that comes to my mind is that u cache all guilds on start and then check which id's are in your db... if its not there, just
cache.delete(id)
idk how efficient this is but this is what i can think of rnSo I recently made this change, however I am hitting a very weird issue with it. I am testing the change on one of my clusters and 5 of the shards (the same ones every restart) seem to never succeed in connecting and are constantly being reconnecting. When I restart the cluster without the changes I had made all shards work normally
The code changes I have only change the GuildMemberManager cache (as well as fetching the guilds in my database on start up to be used with the caching changes)
Is there any reason these caching changes would be preventing some shards from working?
any insight is appreciated, I can give more logs if needed (I am currently logging with the debug event)
additional context, the shards which go offline, all have a number of guilds unavailable at startup:
I guess that would make sense why the same shards are being affected if those shards have large servers on them
I have GuildPresences, and VoiceStateManager is disabled
Would there be any way to work around this? can I increase the ready timeout?
Any risk involved with increasing it I should be aware of?
I incrased the timeout from the default 15 seconds to 60 seconds, this seems to have fixed the issue for 2 of the shards while 3 of the shards still fail to start on time, I will try again with a larger timeout
even with a timeout of 3 minutes the shards seem to always timeout
the number of unavailable guilds also doesn't seem to change:
Can I add a keepOverLimit to the cache after start up? Essentially start the bot up without one and then once it is ready add the restriction?