Best way to use Preconditions to determine which commands show up in a /help command?
I'm looking to make a dynamic help command that'll show a user all commands available to them, but I'm really not sure how to go about checking to make sure a command is able to be run by the user before adding it to the embed. Currently the core logic for the command looks like so:
I'm familiar with preconditions a bit, but unsure of how sapphire's framework actually does the checking behind the scenes to see if a user passes precondition checks, I was thinking maybe that could be a way I could test each command to see if the author of the message/user of the interaction (for chatInputRun) is able to run the command.
I'm also aware I'll probably have to do some further filtering rather than just getting all the commands from the stores (since I believe there will be duplicate entries for commands that have messageRun/chatInputRun/contextMenuRun methods) but right now I'm focused on just figuring out a good way of figuring out whether or not to include a command based on the user using the help command first. Any ideas?
Solution:Jump to solution
First of all there won't be duplicate entries. The entry will simply have both messageRun and chatInputRun
Secondly, for slash commands you do not need a help command because you have description fields for the commands and options already
Thirdly, you can take inspiration from @Skyra https://github.com/skyra-project/skyra/blob/main/src/commands/General/help.ts#L189-L206...
2 Replies
Solution
First of all there won't be duplicate entries. The entry will simply have both messageRun and chatInputRun
Secondly, for slash commands you do not need a help command because you have description fields for the commands and options already
Thirdly, you can take inspiration from @Skyra https://github.com/skyra-project/skyra/blob/main/src/commands/General/help.ts#L189-L206
Yeah the help command is meant just for showing available messageRun commands, and thank you for the link I definitely will <3