Closed tverghis closed 3 years ago
I wrote up this issue because I'm running into problems splitting out sub-commands from Moderation.js
for #33. I currently can't put those files under a subfolder in the ./lib/commands/
folder, because it breaks the above loader.
(Temporarily 'fixed' this by also adding a filter for my subfolder's name, but it doesn't seem like the correct solution)
You are correct and it should be like that, I think the only reason I wrote it like that was of pure laziness
/index.js:32
: We loop over all the files in the./lib/commands/
directory,require
them, and store therequire
d modules in an array. This array is then passed into the Twitch client to register them as commands. In this process, we need to explicitly avoid loadingCommand.js
, because it's not actually a command that can be called.This has a few drawbacks I can think of:
./lib/commands/
directory, we might need to add exceptions to the load process (likeCommand.js
).Why not just create an
index.js
file in./lib/commands/
that exports only the appropriate commands from the directory? Then all that needs to be done is a simplerequire('./lib/commands')
in the Twitch client.