how do you get access to your instantiated `discordjs.Client` from imported files?
I can't do
export client
and import my main file, because that would create a circular dependency.
how is it usually done?
should i just make client global / attach it to process
?9 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Usually you always have an instance of the class in each file because you provide it or d.js structures. eg message.clinet, interaction.client, etc
but it's not the same instance that i create / login with in my main file
bot.js (my main file)
But it is
Well the loadCommands is kind of weird, what does it do?
It doesn't have any arguments
just trying to load all my commands from separate files
load-commands.js:
Well, you're run your process in main file and you're creating an instance in that file. Therefore you can provide it everywhere you want.
i dont understand
You can provide your client to your loadCommands function parameter
i guess that would work. seems clunky though
think i found a better solution, i moved everything from my main file into
client.js
that exports the client, now my main file is only import commands from './commands.js';
, and the commands file can import the client