Subcommand error questions

Hello, I have only messageCommandDenied listener where I handle precondition errors. But, when subcommand fails it also shares that listener even tho there is specific listener for that. Probably a bug you should look into
Solution:
The plugin does not overwrite the default command handling (like you did before by overwriting the listener) and the subcommand denied error is thrown at a completely different stage in the processing of the command: https://github.com/sapphiredev/plugins/blob/6664087e0b419adcd9ce9411148793e131dd7c3d/packages/subcommands/src/lib/Subcommand.ts#L437 as opposed to https://github.com/sapphiredev/framework/blob/b1fa79bad64e0a17eadd6db2d77fe14eb77c87f7/src/optional-listeners/message-command-listeners/CorePreMessageCommandRun.ts#L15...
Jump to solution
7 Replies
Favna
Favna5mo ago
It depends on whether the precondition is on the parent command or the specific subcommand
čamdžić
čamdžićOP5mo ago
Precondition is global And I do just .money like main command
Favna
Favna5mo ago
then yes that is perfectly correct behaviour
Solution
Favna
Favna5mo ago
The plugin does not overwrite the default command handling (like you did before by overwriting the listener) and the subcommand denied error is thrown at a completely different stage in the processing of the command: https://github.com/sapphiredev/plugins/blob/6664087e0b419adcd9ce9411148793e131dd7c3d/packages/subcommands/src/lib/Subcommand.ts#L437 as opposed to https://github.com/sapphiredev/framework/blob/b1fa79bad64e0a17eadd6db2d77fe14eb77c87f7/src/optional-listeners/message-command-listeners/CorePreMessageCommandRun.ts#L15
čamdžić
čamdžićOP5mo ago
Kk ty
čamdžić
čamdžićOP5mo ago
Can I unapply global precondition on specific command @Boomeravna Like ignore it
Favna
Favna5mo ago
no well sort of I think but at that point you may as well not use global preconditions you need to extend the Command class and add an additional toggable option that you can read in the precondition but at that point you can just pre-define the set of preconditions and you wouldnt need global ones at all and just extend the class with the precondition where you need it

Did you find this page helpful?