Make a stats file?
I am using express and have a router file which I want to use to send
client.guilds.cache.size
. But I don't have access to client because it is in index.js
not routes/stats.js
. If I require index.js
which defines my client it will rerun the whole file and mess it up4 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I prefer not to use some library
You can define your client in a separate file, and then require that file in both your
index.js
and your routes/stats.js
Wouldn't that make a new client every time? So double the websockets?
There should be an option to disable ws so it is ready immediately so you don't have to use rest for things like updating slash commands
Well I can't use rest to access the client.guilds.cache, which is all I want
Well I haven't found a single one don't think express lets you do it
I want the guilds in the cache
guilds.cache.size and a list of names and ids
Ok, but my issue is getting access to those variables because requiring it isn't really a thing I could do, right?
If I require the file it would run it again
Oh
I don't know what more you need
Does this help?
I'm not sure what you need
I managed to do it using middleware