I am trying to find the guild owner ID for all of my guilds to send them a direct message at a given time. My current implementation where I know all the guildIDs already and just iterate through them: message.client.guilds.cache.get(guildID).ownerID
This currently works and is fine but I wonder about its robustness when I increase my guild count. I am currently testing on just 2 guilds but could reach upwards of 1000.
Lots of the older tutorials and questions on this site suggest not needing to use the .cache
property of message.client.guilds
and just getting your desired property like this message.client.guilds.get(desired_property)
However when I try and go by their advice I get an error. This question had a similar problem to the one I was having but then fixed it when I used the .cache
property of message.client
which solved my problem previous problem. I then think I found why as this answer to a similar questions tells me that all user objects have been cached
What will this mean when I have upwards of 1000 guilds? Dont worry about sharding that is something I can think about later.
I have a loose understanding of how a cache works but will this therefore break down when I get into more guilds as not all of the guilds will be cached and therefore when I use message.client.guilds.cache.get(guildID).ownerID
will I only get the ownerIDs of those guilds that have been cached or are all of the guilds the bot is in cached all the time? If this will not always return all the ownerIDs when the bot begins having thousands of guilds and therefore potentially not all of the guilds are cached is there a way in which I can fix it so it will always return them all?
(
[ ${client.guilds.cache.map(g => g.name).join(", \n ")} ]
);