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 up
4 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Isra
IsraOP3y ago
I prefer not to use some library
Squid
Squid3y ago
You can define your client in a separate file, and then require that file in both your index.js and your routes/stats.js
Isra
IsraOP3y ago
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 shrug 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

Did you find this page helpful?