Will the custom path in a store apply also when using cogs (or modules)?
If I have the following code that changes the stores path:
And I also use a cog system that is grouped in a single folder:
Would sapphire, instead of looking for "interaction-handlers" inside each cog, would look instead for the custom path folder name, which would be "interactions"? Same thing with "arguments" being "options"?
If not, how would I accomplish this? Or is there a better way of doing this?
37 Replies
:: Sapphire guide results:
User Guide / Implementing a discord.py like Cog system
:: Sapphire guide results:
User Guide / Registering custom paths for a store
@Favna Yeah, that's exactly what I'm doing
I'm asking if Sapphire will know the new folder names, like I explained in the last paragraph in here
I think it should work yes, but the rule of thumb is https://tryitands.ee
Nope, it doesn't works
It doesn't register the commands, says there were 0 commands registered
Moving the
interactions
or options
folder outside to the src
folder does work though
So, it seems customizing the store's name doesn't works for cogs? How would I get them working?your code looks correct, just make sure the root directory points to the same directory as your main entry in pkg.json
so if your main is dist/index.js for example, your rootpath should start at dist
Yup, it is, yet it doesn't works ðŸ˜
huh, fascinating
can you set Store.logger to console.log or something
and check what it prints (expect spam)
Alright, let me try
do that before calling login btw
💀
this is what i did
i said
set
not log
:CLk_Kekega:
Store.logger = console.log
oh ðŸ˜
this is my custom client, might be helpful
and is the base correct?
bc
its saying /src
and you're in TS land, so unless you're using bun/ts-node/tsx with main: src/entrypoint.ts or w/e in your pkg.json, that will never work
yup im using bun
interesting
do those paths look correct?
this is the directory
should work according to the paths in the custom client, specified here
well your cmds will never load
bc the paths are wrong
wat
this.stores.get("commands").registerPath(path.join(this._rootData.root, "cmds"));
Solution
missing some path elements there arent ya
modules/base
yeah that's what i thought, and it's what i meant in the thread description ðŸ˜
here
if you use registerPath on a store you need to give the full path to the folder
your _registerModule will always work because you tell ALL stores to go to that path and check for their folder
if you want to use a custom folder name.. you'll need to register it for its specific store, full path and all
so it'd have to be like this
this.stores.get("commands").registerPath(path.join(this._rootData.root, "modules", "base", "cmds"));
??si
or rename the cmds folder to commands
:mmLol:
oh ok so i can't set custom paths or folder names for each store when doing
this.stores.registerPath(join(this.rootData.root, 'cogs', 'audio'));
basically, because sapphire would bind to the default namings which would be for example ìnteractions-handler
mhm
that said you can probably optimize this by scanning the dir yourself and doing the mapping but yeah, that be how it be
okok, would this be a bad approach for what i want to accomplish? are there better ways or this is already enough?
yup that's what i was going to do
nop, that works too
of course you can always move away from fs registering to virtual pieces, and then it doesnt matter anymore but idk if we have docs for that yet
okok, that's it for now, tysm 🫶