From 1328ea8c525f1c1ff8d6bd3d991451f5682615d0 Mon Sep 17 00:00:00 2001 From: Cenk Ergen <57065323+Cenngo@users.noreply.github.com> Date: Sun, 2 Jan 2022 16:47:43 +0300 Subject: [PATCH] add user-built AddCommand overloads to ModuleBuilder --- .../Builders/ModuleBuilder.cs | 82 +++++++++++++++++-- 1 file changed, 75 insertions(+), 7 deletions(-) diff --git a/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs b/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs index 73d5ed62f..bcacfbc7a 100644 --- a/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs @@ -159,7 +159,7 @@ namespace Discord.Interactions.Builders } /// - /// Adds attributes to + /// Adds attributes to . /// /// New attributes to be added to . /// @@ -172,7 +172,7 @@ namespace Discord.Interactions.Builders } /// - /// Adds preconditions to + /// Adds preconditions to . /// /// New preconditions to be added to . /// @@ -185,7 +185,7 @@ namespace Discord.Interactions.Builders } /// - /// Adds slash command builder to + /// Adds slash command builder to . /// /// factory. /// @@ -200,7 +200,24 @@ namespace Discord.Interactions.Builders } /// - /// Adds context command builder to + /// Adds slash command builder to . + /// + /// Name of the command. + /// Command callback to be executed. + /// factory. + /// + /// The builder instance. + /// + public ModuleBuilder AddSlashCommand(string name, ExecuteCallback callback, Action configure) + { + var command = new SlashCommandBuilder(this, name, callback); + configure(command); + _slashCommands.Add(command); + return this; + } + + /// + /// Adds context command builder to . /// /// factory. /// @@ -215,7 +232,24 @@ namespace Discord.Interactions.Builders } /// - /// Adds component command builder to + /// Adds slash command builder to . + /// + /// Name of the command. + /// Command callback to be executed. + /// factory. + /// + /// The builder instance. + /// + public ModuleBuilder AddContextCommand(string name, ExecuteCallback callback, Action configure) + { + var command = new ContextCommandBuilder(this, name, callback); + configure(command); + _contextCommands.Add(command); + return this; + } + + /// + /// Adds component command builder to . /// /// factory. /// @@ -230,7 +264,24 @@ namespace Discord.Interactions.Builders } /// - /// Adds autocomplete command builder to + /// Adds slash command builder to . + /// + /// Name of the command. + /// Command callback to be executed. + /// factory. + /// + /// The builder instance. + /// + public ModuleBuilder AddComponentCommand(string name, ExecuteCallback callback, Action configure) + { + var command = new ComponentCommandBuilder(this, name, callback); + configure(command); + _componentCommands.Add(command); + return this; + } + + /// + /// Adds autocomplete command builder to . /// /// factory. /// @@ -245,7 +296,24 @@ namespace Discord.Interactions.Builders } /// - /// Adds sub-module builder to + /// Adds slash command builder to . + /// + /// Name of the command. + /// Command callback to be executed. + /// factory. + /// + /// The builder instance. + /// + public ModuleBuilder AddSlashCommand(string name, ExecuteCallback callback, Action configure) + { + var command = new AutocompleteCommandBuilder(this, name, callback); + configure(command); + _autocompleteCommands.Add(command); + return this; + } + + /// + /// Adds sub-module builder to . /// /// factory. ///