Should i acquire every command or only once
Hello
I just got interest to Sapphire and when i was reading advanced doc for registering commands outside of classes (in my case in a yml file) i saw that acquire a registry is necessary but i was wondering if i have to acquire multiple registry or not ? and also what registry id would be usefull for ?
Thx
Solution:Jump to solution
Usually you get a registry keyed by whatever you want it to be keyed as, usually a command, and then you register commands in it
19 Replies
i dont think i fully understand your question yet? could you explain further
mb my english is a mess. I checked https://www.sapphirejs.dev/docs/Guide/commands/application-commands/application-command-registry/advanced/registering-application-commands-outside-a-command and i see that i need to acquire a registry. Should i acquire multiple registry or only one (for basic usage)
Sapphire Framework
Registering Application Commands outside a Command | Sapphire
You are able to register your application commands inside of their command class, but also outside of the class! Whether
and also should i set a coherent key for the registry ?
You get the registry per command if i remember correctly, @vladdy ?
Yep
Solution
Usually you get a registry keyed by whatever you want it to be keyed as, usually a command, and then you register commands in it
Just saying you need to be really really sure this is what you want to do. You're not making your life easier doing this.
Don't over engineer where no over engineering is necessary is what I always recommend.
TBH as newcomer of Sapphire i dont like the fact of registering commands in the class directly (it's highly subjectif) and that why i want to use yml file (i use JS not TS so i can't use decorator)
Alright you do you
can i ask why we need one registry per command ?
@vladdy designed the whole registry thing so I delegate that question to him too :kekw:
Sorry to bother you on your bday vladdy :dragonheart:
1 registry should point to one piece
1 registry can hold many application commands
Oh I don't mind it lmfao
🎂 vladdy
oh ok and by default Sapphire use one piece for every commands ?
Uh, one registry for one piece, yes
I mean if you build your own mapper, technically speaking you can have any amount of registries and they'll more less work. Just be careful that you don't end up having two registries named differently trying to register the same cmd
so if i do a simple mapper with no notions of multiple pieces, i should only acquire one registry ?
i mean, i dont care of splitting commands in multiple module/piece (at least for now)
Probably yea
thx
Last question: should i register commands in a "ready" event callback or is it safe to register anywhere ?
on the doc it's made in main "scope"
Uhh
Sapphire automatically handles that on ready
Noice, thx