You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed this while upgrading my project from 1.0.0-rc2 (Nuget Prerelease) to 1.0.0 "Final" (also Nuget). It seems parameter preconditions simply never run.
publicclassTestModule:ModuleBase{[Command("test")]publicasync Task DoTest([TestPrecon]stringinput){//this should never happenawait ReplyAsync("Test Succeeded");}}publicclassTestPrecon:ParameterPreconditionAttribute{publicoverrideasyncTask<PreconditionResult>CheckPermissions(ICommandContextcontext,ParameterInfoparameter,objectvalue,IServiceProviderservices){//do some async workvarownerId=(await services.GetService<DiscordSocketClient>().GetApplicationInfoAsync()).Owner.Id;//always return an errorreturn PreconditionResult.FromError("Failure.");}}
With this code, "Test Succeeded" is always sent, regardless of the PreconditionResult being an error result. None of the code within CheckPermissions is executed.
The text was updated successfully, but these errors were encountered:
You can see at this line, during the refactoring that switched it to modern C# 7 pattern matching, ParameterPreconditionAttribute was mistakenly removed. In a local test build, simply adding the following to the top of the switch block fixed the issue:
I noticed this while upgrading my project from 1.0.0-rc2 (Nuget Prerelease) to 1.0.0 "Final" (also Nuget). It seems parameter preconditions simply never run.
Here is a simple repro, which I used in conjunction with the Command Service example in the documentation.
With this code, "Test Succeeded" is always sent, regardless of the PreconditionResult being an error result. None of the code within
CheckPermissions
is executed.The text was updated successfully, but these errors were encountered: