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 intoSolution:Jump to 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...
7 Replies
It depends on whether the precondition is on the parent command or the specific subcommand
Precondition is global
And I do just .money like main command
then yes that is perfectly correct behaviour
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
Kk ty
Can I unapply global precondition on specific command @Boomeravna
Like ignore it
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