#Basic js question
27 messages · Page 1 of 1 (latest)
- 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!
yes, have you tried it yet?
I'm coding after a long time so lacking basics
I'm gonna try it sir
No
It's not a right way ?
no
Umm then sir ?
What's the correct way to do it
when you create sharder object you should pass by value through functions to where you need the properties in other files
const sharder = new Client(...)
// later , when you are reading command files maybe
command.execute(interaction, sharder)
// in file of command
execute(interaction, sharder) {
// can use sharder here
}
But i'm using it differently
const sharder = new ShardClient(shardOptions)
sharder.spawn()
module.exports = sharder
That's all now i wanna use sharder to use it properties when i use eval command so importing it is not an option cuz I'm not loading any cmds or anything nd they r in different files
you said you have eval command what do you mean you are not loading any commands
Eval command is in commands folder and shard.js where I'm exporting it is a seperate file only for sharding
My sharder starts my cluster, client and then deploys cmds but in a seperate file but i only wanna use it in eval cmd so...
Ok there is another way
use client.shard.broadcastEval
I can't the properties i wanna use is in sharder thing and i need to do sharder.ipc... like this
So any way to export my sharder then import it somewhere else
ok
ignore what i said before
you can do what you posted in the first message
but do not reassign anything, it is static and will end up being cached because you are exporting it
it is just bad practice if you are not using something like a singleton
and even then it is discouraged with exporting client for example
if that's your sharder wouldn't it run in a completely different process than your eval command?