Use commands from src and also from custom package in node_modules (Programatically add commands?)

There's probably a better way to do this, but wrapping my head around how I want to approach it. I'm working on a variety of smaller NPM packages that I intend to use across a bunch of different bots/projects. One of these packages, I want to have a debug command - without having to specify what that command is/does inside of each project - I only want to specify it once at the package level, as all projects will use it the same. For this package, it exports a class, that is instantiated immediately after the project connects to the client. When this class is initialized, it takes in the SapphireClient - so I assume I can do something with this from here. |-- node_modules |-- |-- package |-- |-- |-- Commands |-- src |-- | --Commands If I have the client object - what's the best approach I should take, to be able to run commands from the package and commands from the src?
Solution:
Sapphire has the ability to load plugins from npm packages, meaning that you can load those stores into your bot. https://github.com/sapphiredev/plugins has examples
Jump to solution
5 Replies
Bejasc
Bejasc•2y ago
not against providing some config at the project level to register an additional dir to read commands from or something - just don't want to write the command itself more than once or maybe the best way is to simply provide the token instead of the client, and connect to the client twice, effectively? Tried this and it works, but doesn't take advantage of - if the project has listeners for MessageCommandAccepted.ts etc - they'd have to be implemented at the package level Interested to hear thoughts on the best approach 🙂
Sean
Sean•2y ago
The plugin system lol
Bejasc
Bejasc•2y ago
would you care to explain a little more?
Solution
Sean
Sean•2y ago
Sapphire has the ability to load plugins from npm packages, meaning that you can load those stores into your bot. https://github.com/sapphiredev/plugins has examples
Bejasc
Bejasc•2y ago
thanks, I'll look through that
Want results from more Discord servers?
Add your server