Sapphire - Imagine a framework
Sapphire - Imagine a framework

sapphire-support

Root Question Message

Bejasc
Bejasc12/28/2022
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?
Bejasc
Bejasc12/28/2022
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
Bejasc
Bejasc12/28/2022
or maybe the best way is to simply provide the token instead of the client, and connect to the client twice, effectively?
Bejasc
Bejasc12/28/2022
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
Bejasc
Bejasc12/28/2022
Interested to hear thoughts on the best approach 🙂
const name = args.pick('sean');
const name = args.pick('sean');12/28/2022
The plugin system lol
Bejasc
Bejasc12/28/2022
would you care to explain a little more?
const name = args.pick('sean');
const name = args.pick('sean');12/28/2022
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
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy