Skip to content

Commit 68e3bed

Browse files
authored
Add user-built AddCommand overloads to ModuleBuilder (#2015)
* add user-built AddCommand overloads to ModuleBuilder * fix inline docs
1 parent 093e548 commit 68e3bed

File tree

1 file changed

+75
-7
lines changed

1 file changed

+75
-7
lines changed

src/Discord.Net.Interactions/Builders/ModuleBuilder.cs

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public ModuleBuilder WithDefaultPermision (bool permission)
159159
}
160160

161161
/// <summary>
162-
/// Adds attributes to <see cref="Attributes"/>
162+
/// Adds attributes to <see cref="Attributes"/>.
163163
/// </summary>
164164
/// <param name="attributes">New attributes to be added to <see cref="Attributes"/>.</param>
165165
/// <returns>
@@ -172,7 +172,7 @@ public ModuleBuilder AddAttributes (params Attribute[] attributes)
172172
}
173173

174174
/// <summary>
175-
/// Adds preconditions to <see cref="Preconditions"/>
175+
/// Adds preconditions to <see cref="Preconditions"/>.
176176
/// </summary>
177177
/// <param name="preconditions">New preconditions to be added to <see cref="Preconditions"/>.</param>
178178
/// <returns>
@@ -185,7 +185,7 @@ public ModuleBuilder AddPreconditions (params PreconditionAttribute[] preconditi
185185
}
186186

187187
/// <summary>
188-
/// Adds slash command builder to <see cref="SlashCommands"/>
188+
/// Adds slash command builder to <see cref="SlashCommands"/>.
189189
/// </summary>
190190
/// <param name="configure"><see cref="SlashCommandBuilder"/> factory.</param>
191191
/// <returns>
@@ -200,7 +200,24 @@ public ModuleBuilder AddSlashCommand (Action<SlashCommandBuilder> configure)
200200
}
201201

202202
/// <summary>
203-
/// Adds context command builder to <see cref="ContextCommands"/>
203+
/// Adds slash command builder to <see cref="SlashCommands"/>.
204+
/// </summary>
205+
/// <param name="name">Name of the command.</param>
206+
/// <param name="callback">Command callback to be executed.</param>
207+
/// <param name="configure"><see cref="SlashCommandBuilder"/> factory.</param>
208+
/// <returns>
209+
/// The builder instance.
210+
/// </returns>
211+
public ModuleBuilder AddSlashCommand(string name, ExecuteCallback callback, Action<SlashCommandBuilder> configure)
212+
{
213+
var command = new SlashCommandBuilder(this, name, callback);
214+
configure(command);
215+
_slashCommands.Add(command);
216+
return this;
217+
}
218+
219+
/// <summary>
220+
/// Adds context command builder to <see cref="ContextCommands"/>.
204221
/// </summary>
205222
/// <param name="configure"><see cref="ContextCommandBuilder"/> factory.</param>
206223
/// <returns>
@@ -215,7 +232,24 @@ public ModuleBuilder AddContextCommand (Action<ContextCommandBuilder> configure)
215232
}
216233

217234
/// <summary>
218-
/// Adds component command builder to <see cref="ComponentCommands"/>
235+
/// Adds context command builder to <see cref="ContextCommands"/>.
236+
/// </summary>
237+
/// <param name="name">Name of the command.</param>
238+
/// <param name="callback">Command callback to be executed.</param>
239+
/// <param name="configure"><see cref="ContextCommandBuilder"/> factory.</param>
240+
/// <returns>
241+
/// The builder instance.
242+
/// </returns>
243+
public ModuleBuilder AddContextCommand(string name, ExecuteCallback callback, Action<ContextCommandBuilder> configure)
244+
{
245+
var command = new ContextCommandBuilder(this, name, callback);
246+
configure(command);
247+
_contextCommands.Add(command);
248+
return this;
249+
}
250+
251+
/// <summary>
252+
/// Adds component command builder to <see cref="ComponentCommands"/>.
219253
/// </summary>
220254
/// <param name="configure"><see cref="ComponentCommandBuilder"/> factory.</param>
221255
/// <returns>
@@ -230,7 +264,24 @@ public ModuleBuilder AddComponentCommand (Action<ComponentCommandBuilder> config
230264
}
231265

232266
/// <summary>
233-
/// Adds autocomplete command builder to <see cref="AutocompleteCommands"/>
267+
/// Adds component command builder to <see cref="ComponentCommands"/>.
268+
/// </summary>
269+
/// <param name="name">Name of the command.</param>
270+
/// <param name="callback">Command callback to be executed.</param>
271+
/// <param name="configure"><see cref="ComponentCommandBuilder"/> factory.</param>
272+
/// <returns>
273+
/// The builder instance.
274+
/// </returns>
275+
public ModuleBuilder AddComponentCommand(string name, ExecuteCallback callback, Action<ComponentCommandBuilder> configure)
276+
{
277+
var command = new ComponentCommandBuilder(this, name, callback);
278+
configure(command);
279+
_componentCommands.Add(command);
280+
return this;
281+
}
282+
283+
/// <summary>
284+
/// Adds autocomplete command builder to <see cref="AutocompleteCommands"/>.
234285
/// </summary>
235286
/// <param name="configure"><see cref="AutocompleteCommands"/> factory.</param>
236287
/// <returns>
@@ -245,7 +296,24 @@ public ModuleBuilder AddAutocompleteCommand(Action<AutocompleteCommandBuilder> c
245296
}
246297

247298
/// <summary>
248-
/// Adds sub-module builder to <see cref="SubModules"/>
299+
/// Adds autocomplete command builder to <see cref="AutocompleteCommands"/>.
300+
/// </summary>
301+
/// <param name="name">Name of the command.</param>
302+
/// <param name="callback">Command callback to be executed.</param>
303+
/// <param name="configure"><see cref="AutocompleteCommandBuilder"/> factory.</param>
304+
/// <returns>
305+
/// The builder instance.
306+
/// </returns>
307+
public ModuleBuilder AddSlashCommand(string name, ExecuteCallback callback, Action<AutocompleteCommandBuilder> configure)
308+
{
309+
var command = new AutocompleteCommandBuilder(this, name, callback);
310+
configure(command);
311+
_autocompleteCommands.Add(command);
312+
return this;
313+
}
314+
315+
/// <summary>
316+
/// Adds sub-module builder to <see cref="SubModules"/>.
249317
/// </summary>
250318
/// <param name="configure"><see cref="ModuleBuilder"/> factory.</param>
251319
/// <returns>

0 commit comments

Comments
 (0)