diff --git a/src/Discord.Net.Commands/Builders/ModuleBuilder.cs b/src/Discord.Net.Commands/Builders/ModuleBuilder.cs index c6349712b..0189ceaca 100644 --- a/src/Discord.Net.Commands/Builders/ModuleBuilder.cs +++ b/src/Discord.Net.Commands/Builders/ModuleBuilder.cs @@ -126,7 +126,7 @@ namespace Discord.Commands.Builders try { var moduleInstance = ReflectionUtils.CreateObject(TypeInfo, service, services); - moduleInstance.OnModuleBuilding(service); + moduleInstance.OnModuleBuilding(service, this); } catch (Exception) { diff --git a/src/Discord.Net.Commands/IModuleBase.cs b/src/Discord.Net.Commands/IModuleBase.cs index 89559b9a8..3b641ec5f 100644 --- a/src/Discord.Net.Commands/IModuleBase.cs +++ b/src/Discord.Net.Commands/IModuleBase.cs @@ -1,3 +1,5 @@ +using Discord.Commands.Builders; + namespace Discord.Commands { internal interface IModuleBase @@ -8,6 +10,6 @@ namespace Discord.Commands void AfterExecute(CommandInfo command); - void OnModuleBuilding(CommandService commandService); + void OnModuleBuilding(CommandService commandService, ModuleBuilder builder); } } diff --git a/src/Discord.Net.Commands/ModuleBase.cs b/src/Discord.Net.Commands/ModuleBase.cs index ec3d35e5b..28fa4a96c 100644 --- a/src/Discord.Net.Commands/ModuleBase.cs +++ b/src/Discord.Net.Commands/ModuleBase.cs @@ -1,3 +1,4 @@ +using Discord.Commands.Builders; using System; using System.Threading.Tasks; @@ -23,7 +24,7 @@ namespace Discord.Commands { } - protected virtual void OnModuleBuilding(CommandService commandService) + protected virtual void OnModuleBuilding(CommandService commandService, ModuleBuilder builder) { } @@ -33,11 +34,8 @@ namespace Discord.Commands var newValue = context as T; Context = newValue ?? throw new InvalidOperationException($"Invalid context type. Expected {typeof(T).Name}, got {context.GetType().Name}"); } - void IModuleBase.BeforeExecute(CommandInfo command) => BeforeExecute(command); - void IModuleBase.AfterExecute(CommandInfo command) => AfterExecute(command); - - void IModuleBase.OnModuleBuilding(CommandService commandService) => OnModuleBuilding(commandService); + void IModuleBase.OnModuleBuilding(CommandService commandService, ModuleBuilder builder) => OnModuleBuilding(commandService, builder); } }