diff --git a/src/NadekoBot/Common/Medusa/MedusaLoaderService.cs b/src/NadekoBot/Common/Medusa/MedusaLoaderService.cs index 4fca69e72..246552295 100644 --- a/src/NadekoBot/Common/Medusa/MedusaLoaderService.cs +++ b/src/NadekoBot/Common/Medusa/MedusaLoaderService.cs @@ -459,6 +459,9 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor, pb.WithIsMultiple(paramData.IsParams) .WithIsOptional(paramData.IsOptional) .WithIsRemainder(paramData.IsLeftover); + + if (paramData.IsOptional) + pb.WithDefault(paramData.DefaultValue); }; [MethodImpl(MethodImplOptions.NoInlining)] @@ -800,6 +803,7 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor, var leftoverAttribute = pi.GetCustomAttribute(true); var hasDefaultValue = pi.HasDefaultValue; + var defaultValue = pi.DefaultValue; var isLeftover = leftoverAttribute != null; var isParams = pi.GetCustomAttribute() is not null; var paramType = pi.ParameterType; @@ -836,7 +840,7 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor, continue; } - canInject = false; + canInject = false; if (isParams) { @@ -857,7 +861,7 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor, throw new ArgumentException("Leftover attribute error."); } - cmdParams.Add(new ParamData(paramType, paramName, hasDefaultValue, isLeftover, isParams)); + cmdParams.Add(new ParamData(paramType, paramName, hasDefaultValue, defaultValue, isLeftover, isParams)); } diff --git a/src/NadekoBot/Common/Medusa/Models/ParamData.cs b/src/NadekoBot/Common/Medusa/Models/ParamData.cs index acb3b5008..dc38791a1 100644 --- a/src/NadekoBot/Common/Medusa/Models/ParamData.cs +++ b/src/NadekoBot/Common/Medusa/Models/ParamData.cs @@ -4,6 +4,7 @@ public sealed record ParamData( Type Type, string Name, bool IsOptional, + object? DefaultValue, bool IsLeftover, bool IsParams ); \ No newline at end of file