Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
91629dd
Add xml docs for builders and partial docs for contexts
KubaZ2 Sep 1, 2025
e107eb0
Add more xml docs for contexts
KubaZ2 Sep 1, 2025
82ed22d
Add (I)ApplicationCommandService xml docs
KubaZ2 Sep 1, 2025
cd98f8a
Add xml docs for IApplicationCommandInfo and small refactor
KubaZ2 Sep 1, 2025
e2bdaf1
Merge branch 'alpha' into feature/services-xml-docs
KubaZ2 Nov 5, 2025
e67cce1
Resolve merge conflict resolve errors
KubaZ2 Nov 5, 2025
67c81df
Fix whitespace
KubaZ2 Nov 5, 2025
3869c73
Clarify AddModules method documentation
KubaZ2 Nov 5, 2025
4545b7a
Add xml docs for `ApplicationCommandServiceManager`
KubaZ2 Nov 5, 2025
efa774d
Add XML documentation to IApplicationCommandService
KubaZ2 Nov 5, 2025
6199e21
Add xml docs to app command modules
KubaZ2 Nov 5, 2025
4d80bfa
Add xml docs to component interaction modules
KubaZ2 Nov 5, 2025
212f45d
Improve XML documentation and enhance code clarity
KubaZ2 Nov 5, 2025
f6f8260
Add xml docs for command service
KubaZ2 Nov 5, 2025
3f14a1e
Add xml docs for command modules
KubaZ2 Nov 5, 2025
6cd3c74
Make base modules abstract
KubaZ2 Nov 5, 2025
f1c3617
Add xml docs for UserId
KubaZ2 Nov 5, 2025
276fddb
Add xml docs for command and component interaction builders
KubaZ2 Nov 5, 2025
90fe449
Remove `abstract` modifier from `IApplicationCommandInfo.Type`
KubaZ2 Nov 5, 2025
94af686
Remove xml docs from `IApplicationCommandInfo`
KubaZ2 Nov 5, 2025
72c25da
Reformat `ICommandInfo`
KubaZ2 Nov 5, 2025
e0607d3
Simplify XML documentation for parameters
KubaZ2 Nov 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions NetCord.Services/ApplicationCommands/ApplicationCommandBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
namespace NetCord.Services.ApplicationCommands;

/// <inheritdoc cref="ApplicationCommandAttribute" />
[GenerateMethodsForProperties]
public abstract partial class ApplicationCommandBuilder
{
/// <inheritdoc cref="ApplicationCommandAttribute.Name" />
public string Name { get; }

/// <inheritdoc cref="ApplicationCommandAttribute.DefaultGuildPermissions" />
public Permissions? DefaultGuildPermissions { get; set; }

/// <inheritdoc cref="ApplicationCommandAttribute.IntegrationTypes" />
public IEnumerable<ApplicationIntegrationType>? IntegrationTypes { get; set; }

/// <inheritdoc cref="ApplicationCommandAttribute.Contexts" />
public IEnumerable<InteractionContextType>? Contexts { get; set; }

/// <inheritdoc cref="ApplicationCommandAttribute.Nsfw" />
public bool Nsfw { get; set; }

/// <inheritdoc cref="ApplicationCommandAttribute.Register" />
public bool Register { get; set; } = true;

private protected ApplicationCommandBuilder(string name)
Expand All @@ -21,36 +28,66 @@ private protected ApplicationCommandBuilder(string name)
}
}

/// <inheritdoc cref="SlashCommandAttribute" />
/// <param name="name" />
/// <param name="description" />
/// <param name="handler"><inheritdoc cref="Handler" path="/summary" /></param>
[GenerateMethodsForProperties]
public partial class SlashCommandBuilder(string name, string description, Delegate handler) : ApplicationCommandBuilder(name)
{
/// <inheritdoc cref="SlashCommandAttribute.Description" />
public string Description => description;

/// <summary>
/// Handler that represents the body of the command.
/// </summary>
public Delegate Handler => handler;
}

/// <inheritdoc cref="SlashCommandAttribute" />
/// <param name="name" />
/// <param name="description" />
[GenerateMethodsForProperties]
public partial class SlashCommandGroupBuilder(string name, string description) : ApplicationCommandBuilder(name)
{
internal readonly List<SubSlashCommandBuilder> _subCommandBuilders = [];
internal readonly List<SubSlashCommandGroupBuilder> _subCommandGroupBuilders = [];

/// <inheritdoc cref="SlashCommandAttribute.Description" />
public string Description => description;

/// <summary>
/// Adds a sub command to a command group.
/// </summary>
/// <param name="name"><inheritdoc cref="SubSlashCommandBuilder.Name" path="/summary" /></param>
/// <param name="description"><inheritdoc cref="SubSlashCommandBuilder.Description" path="/summary" /></param>
/// <param name="handler"><inheritdoc cref="SubSlashCommandBuilder.Handler" path="/summary" /></param>
/// <returns>The created sub command builder.</returns>
public SubSlashCommandBuilder AddSubCommand(string name, string description, Delegate handler)
{
SubSlashCommandBuilder result = new(name, description, handler);
_subCommandBuilders.Add(result);
return result;
}

/// <summary>
/// Adds a sub command group to a command group.
/// </summary>
/// <param name="name"><inheritdoc cref="SubSlashCommandGroupBuilder.Name" path="/summary" /></param>
/// <param name="description"><inheritdoc cref="SubSlashCommandGroupBuilder.Description" path="/summary" /></param>
/// <returns>The created sub command group builder.</returns>
public SubSlashCommandGroupBuilder AddSubCommandGroup(string name, string description)
{
SubSlashCommandGroupBuilder result = new(name, description);
_subCommandGroupBuilders.Add(result);
return result;
}

/// <inheritdoc cref="AddSubCommandGroup(string, string)" />
/// <param name="name" />
/// <param name="description" />
/// <param name="builder">A delegate that builds the sub command group.</param>
/// <returns>The created sub command group builder.</returns>
public SubSlashCommandGroupBuilder AddSubCommandGroup(string name, string description, Action<SubSlashCommandGroupBuilder> builder)
{
SubSlashCommandGroupBuilder result = new(name, description);
Expand All @@ -60,24 +97,40 @@ public SubSlashCommandGroupBuilder AddSubCommandGroup(string name, string descri
}
}

/// <inheritdoc cref="SubSlashCommandAttribute" />
/// <param name="name" />
/// <param name="description" />
/// <param name="handler"><inheritdoc cref="Handler" path="/summary" /></param>
[GenerateMethodsForProperties]
public partial class SubSlashCommandBuilder(string name, string description, Delegate handler)
{
/// <inheritdoc cref="ApplicationCommandBuilder.Name" />
public string Name => name;

/// <inheritdoc cref="SlashCommandBuilder.Description" />
public string Description => description;

/// <summary>
/// Handler that represents the body of the command.
/// </summary>
public Delegate Handler => handler;
}

/// <inheritdoc cref="SubSlashCommandAttribute" />
/// <param name="name" />
/// <param name="description" />
[GenerateMethodsForProperties]
public partial class SubSlashCommandGroupBuilder(string name, string description)
{
internal readonly List<SubSlashCommandBuilder> _subCommands = [];

/// <inheritdoc cref="ApplicationCommandBuilder.Name" />
public string Name => name;

/// <inheritdoc cref="SlashCommandBuilder.Description" />
public string Description => description;

/// <inheritdoc cref="SlashCommandGroupBuilder.AddSubCommand(string, string, Delegate)" />
public SubSlashCommandBuilder AddSubCommand(string name, string description, Delegate handler)
{
SubSlashCommandBuilder result = new(name, description, handler);
Expand All @@ -86,22 +139,41 @@ public SubSlashCommandBuilder AddSubCommand(string name, string description, Del
}
}

/// <inheritdoc cref="UserCommandAttribute" />
/// <param name="name" />
/// <param name="handler"><inheritdoc cref="Handler" path="/summary" /></param>
[GenerateMethodsForProperties]
public partial class UserCommandBuilder(string name, Delegate handler) : ApplicationCommandBuilder(name)
{
/// <summary>
/// Handler that represents the body of the command.
/// </summary>
public Delegate Handler => handler;
}

/// <inheritdoc cref="MessageCommandAttribute" />
/// <param name="name" />
/// <param name="handler"><inheritdoc cref="Handler" path="/summary" /></param>
[GenerateMethodsForProperties]
public partial class MessageCommandBuilder(string name, Delegate handler) : ApplicationCommandBuilder(name)
{
/// <summary>
/// Handler that represents the body of the command.
/// </summary>
public Delegate Handler => handler;
}

/// <inheritdoc cref="EntryPointCommandAttribute" />
/// <param name="name" />
/// <param name="description" />
[GenerateMethodsForProperties]
public partial class EntryPointCommandBuilder(string name, string description) : ApplicationCommandBuilder(name)
{
/// <inheritdoc cref="EntryPointCommandAttribute.Description" />
public string Description => description;

/// <summary>
/// Handler that represents the body of the command.
/// </summary>
public Delegate? Handler { get; set; }
}
Loading