Let's users have custom folders for pieces

As the title states, I think sapphire should let people place commands, listeners and interaction handlers...etc( all pieces ) in custom folders. Maybe sapphire should let people set the paths of those pieces in SapphireClientOptions.
Solution:
Already possible. You can register a path for a store. If it is for a single store then use ```ts <this>.container.stores.get('mystore').registerPath('path/to/the/folder/here')...
Jump to solution
12 Replies
Solution
Favna
Favna2y ago
Already possible. You can register a path for a store. If it is for a single store then use
<this>.container.stores.get('mystore').registerPath('path/to/the/folder/here')
<this>.container.stores.get('mystore').registerPath('path/to/the/folder/here')
If the path has subsequent folders of commands, listeners etc (i.e. a more DPy strategy of using cogs) then you can use
<this>.container.client.stores.registerPath('/path/to/folder/with/subfolders/here')
<this>.container.client.stores.registerPath('/path/to/folder/with/subfolders/here')
Ideally you would put these in an overloaded constructor of a SapphireClient, so something like:
export class MyCustomClient extends SapphireClient {
public constructor(options: ClientOptions) {
super(options);

this.stores.get('interaction-handlers').registerPath(join(someDirWhereTheFolderIs, 'interactions'));
// or for cog system
this.stores.registerPath(join(someDirWhereTheFolderIs, 'cog-module'));
}
}
export class MyCustomClient extends SapphireClient {
public constructor(options: ClientOptions) {
super(options);

this.stores.get('interaction-handlers').registerPath(join(someDirWhereTheFolderIs, 'interactions'));
// or for cog system
this.stores.registerPath(join(someDirWhereTheFolderIs, 'cog-module'));
}
}
Docs: https://www.sapphirejs.dev/docs/Documentation/api-pieces/classes/Store#registerpath and https://www.sapphirejs.dev/docs/Documentation/api-pieces/classes/StoreRegistry#registerpath
Naryani Priya
Naryani Priya2y ago
How
Favna
Favna2y ago
yeah I was still getting links ill edit that msg
Naryani Priya
Naryani Priya2y ago
So you mean I can place my interaction-handlers in a folder named handlers?
Ararou 🍭
Ararou 🍭2y ago
if it extends InteractionHandler, probably i don't think it matters where you put it just as long it extends one of the classes
Naryani Priya
Naryani Priya2y ago
GitHub
lofi-girl/index.ts at master · Greensky-gs/lofi-girl
Lofi girl bot's source code. Contribute to Greensky-gs/lofi-girl development by creating an account on GitHub.
Naryani Priya
Naryani Priya2y ago
Ok
Favna
Favna2y ago
edited @Naryani Priya
Naryani Priya
Naryani Priya2y ago
Thanks
chillihero
chillihero2y ago
just to clarify for me, you can add helperfiles as pieces and the hmr will then reload this files on change too?
Favna
Favna2y ago
If they're in a store, yes But that's not so much adding a custom folder for an existing store as it is creating your own new store Not to mention this PR is done and ready for review
Spinel
Spinel2y ago
GitHub Pull Request data for @Chillihero: <:_:864240877479657482> #415 in sapphiredev/plugins by favna opened <t:1675012551:R> feat: add utilities-store plugin