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:
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
Jump to solution
19 Replies
Oreo ™
Oreo ™8mo ago
i dont think i fully understand your question yet? could you explain further
WeeskyBDW
WeeskyBDWOP8mo ago
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
WeeskyBDW
WeeskyBDWOP8mo ago
and also should i set a coherent key for the registry ?
Favna
Favna8mo ago
You get the registry per command if i remember correctly, @vladdy ?
vladdy
vladdy8mo ago
Yep
Solution
vladdy
vladdy8mo ago
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
Favna
Favna8mo ago
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.
WeeskyBDW
WeeskyBDWOP8mo ago
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)
Favna
Favna8mo ago
Alright you do you
WeeskyBDW
WeeskyBDWOP8mo ago
can i ask why we need one registry per command ?
Favna
Favna8mo ago
@vladdy designed the whole registry thing so I delegate that question to him too :kekw: Sorry to bother you on your bday vladdy :dragonheart:
vladdy
vladdy8mo ago
1 registry should point to one piece 1 registry can hold many application commands Oh I don't mind it lmfao
WeeskyBDW
WeeskyBDWOP8mo ago
🎂 vladdy oh ok and by default Sapphire use one piece for every commands ?
vladdy
vladdy8mo ago
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
WeeskyBDW
WeeskyBDWOP8mo ago
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)
vladdy
vladdy8mo ago
Probably yea
WeeskyBDW
WeeskyBDWOP8mo ago
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"
vladdy
vladdy8mo ago
Uhh Sapphire automatically handles that on ready
WeeskyBDW
WeeskyBDWOP8mo ago
Noice, thx
Want results from more Discord servers?
Add your server