What is a Piece?
I often read this term but dont really understand it
Solution:Jump to solution
A "piece" is literally a "piece" of your code. Every Sapphire class (commands, preconditions, arguments, listeners, etc) extend the Piece class. Pieces have some properties that are therefore available on all of those classes.
48 Replies
Solution
A "piece" is literally a "piece" of your code. Every Sapphire class (commands, preconditions, arguments, listeners, etc) extend the Piece class. Pieces have some properties that are therefore available on all of those classes.
Historically it's also a hold over from where Sapphire originated from. Sapphire spawned from Klasa (https://github.com/dirigeants/klasa/) which itself spawned from Komada (https://github.com/UnseenFaith/komada), and Komada is literally the Croatian word for "pieces"
is this apply options the same thing as in the super constructor?
those are properties of a piece correct?
no because the top one has subcommands and the bottom one enabled: true
but if those differences wouldnt be there, yes
@ApplyOptions
creates a constructor and .. Applies.. Options..do I need to set the values in both or is it enough if I declared them in one
oh interesting
in fact you cannot use a normal constructor when using @ApplyOptions
it will be overriden
this is a new area for me
I mean that's moreso a thing of decorators than of pieces in general
is there some documentation on the different properties that we can set there?
You're using VSCode. You can just use intellisense. Should be Ctrl + Space
or you can just ctrl+click on the
Options
part of Subcommand.Options
jup but the things itself are not really described
for example the difference between description and detaileddescription\
well we have a website
anyway
as for those in particular
neither is natively read by Sapphire
but you can use either when you want to write a help command
that said if you use slash commands then you only really need description
if you use message commands and write a help command you can use detailedDescription to stuff detailed information in there such as usage, examples, etc
detailedDescription is an interface (forgot the name) on which you can define required properties with module augmentation
whats fullcategory & flags?
ah and how is the name set? because I never set that anywhere and it still registers the correct Name
so you can get like
etc
@Hyperfire well i guess this was your issue :joythink:
I just extended command
Smh
fullCategory, category and all such related are set based on the folder it is in. For example if the structure is
then the
fullCategory
is ['category', 'subcategory']
You normally don't set the property manually through options as it is resolved automatically from the path as shown here. But if you want to overwrite this automatic resolution, then you set it.keyword: was
if it's just for that usage then I strongly recommend using detailedDescription. It's far less complex.
Shut
It's for more than that
fair
I have a hidden flag for hiding from help command and stuff
And examples
And usage
.
I mean you can also put hidden in there
you can put literally anything in there
Yeah
much easier than extending the command class
Idk it was also just a good opportunity to get a better understanding of TS and how extending stuff works
extending classes isn't a TS thing, it's base JS*
but I get what you mean I guess
i did the same and thought of removing the extended class
but never got around to
should be this. Then when you write
detailedDescription
in your options it will expect those 3 properties to be defined.
urgh should probably add this to the guide too but I always find it so hard where to put itwriting goood docs is a superpower tbh
i think your best option would to rewrite how it's done imo
huh
like needing to add
.catch(() => null);
to argscould you also explain how the name is set automatically & what flag does?
:shrug:
what why would you need that
args.pick('string')
does not return null
if we need to do if (!string)
args.pickResult
no thank
use slash commands then
better
fair
name is the file name, or whatever you set
and https://www.sapphirejs.dev/docs/Guide/arguments/using-flags
Sapphire Framework
Using flags | Sapphire
So far we have covered arguments, which are positional - i.e., the order of the arguments matters and they are parsed in
super helpful, thank you favna