Custom Store not working
Hey guys,
I tried myself on writing a custom store
I try to register it in my client with this code piece
Log output:
Path should be correct. But at the end no store will be registered. My stores are all built like this
In the end it's not working. Funny thing is that when I try to register the store manually with
the Service is registered in the store.
Log output:
What am I doing wrong?
I am thankful for all help 🥲
Solution:Jump to solution
specifically plugins dont do
this.stores.register(new InfrastructureDiscordServiceStore())
but this.stores.register(this.server.routes)
and assign this.server
beforehand. They also dont do registerPath
which is implied to be join(getRootData().root, nameOfTheStore)
9 Replies
have you tried mimicking how stores are registered for plugins?
Solution
specifically plugins dont do
this.stores.register(new InfrastructureDiscordServiceStore())
but this.stores.register(this.server.routes)
and assign this.server
beforehand. They also dont do registerPath
which is implied to be join(getRootData().root, nameOfTheStore)
Yes I tried to, but I'm not sure how, where and when to mimick the preInitialization hook for example from the util-store plugin from the register.ts. I understand the logic but I'm not sure how am I supposed to do it. Are there any examples on custom stores outside of the plugins?
how, where and when to mimick the preInitialization hookin your entrypoint file. index.ts, setup.ts, etc.
Can I use hooks like as the plugins use? As for some services I need a logged in Bot for example.
2nd question:
Can I still do the .registerPath() method somewhere in the files then? My pieces do not live in the path
join(getRootData().root, nameOfTheStore)
as I'm using some other folder structureyes and yes
Alright. I tried to copy and edit the most of the utilities plugin.
This is my store register call
Now there are 2 paths set. First the
discord-bot\dist\infrastructure\discord\service
and discord-bot\dist\discordServices
. I tried to set paths in the Store itself. How can I prevent the 2nd store path prevent beeing registered?uhm not sure tbh
but it doesnt really matter
just dont create the direct ory and dont put files in it
take for example sapphire Args. If I dont have Args that doesnt mean that the Argument store doesnt have the path registered. It's just sitting there doing nothing.
Alright, then this will do the trick. It's working by now. Thanks for the help :PES_CowboyLove: