Skip to content

Commit cf13767

Browse files
authored
Add/improve xml comments for commands and interactions (#124)
* Add xml comments for application command properties and for application command attributes * Add xml comments for `SubSlashCommandAttribute` * Add xml docs for slash command parameter and choice attributes * Add xml docs for `CommandAttribute` and refactor a bit * Add xml comments for `CommandParameterAttribute` and revert previous refactor partially * Revert the previous refactor completely * Add xml docs for component interactions * Remove AttributeUsage * Fix MaxValue xml comment * Fix an xml comment of SlashCommandProperties * Improve formality
1 parent 5d23aeb commit cf13767

20 files changed

Lines changed: 137 additions & 24 deletions

Documentation/guides/services/application-commands/Localizations/AnimalModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ public enum Animal
1717
Dog,
1818
Cat,
1919
Fish,
20-
[SlashCommandChoice("Guinea Pig")]
20+
[SlashCommandChoice(Name = "Guinea Pig")]
2121
GuineaPig,
2222
}

Documentation/guides/services/application-commands/Parameters/Animal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ public enum Animal
77
Dog,
88
Cat,
99
Fish,
10-
[SlashCommandChoice("Guinea Pig")]
10+
[SlashCommandChoice(Name = "Guinea Pig")]
1111
GuineaPig,
1212
}

NetCord.Services/ApplicationCommands/ApplicationCommandAttribute.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace NetCord.Services.ApplicationCommands;
22

3+
/// <inheritdoc cref="Rest.ApplicationCommandProperties" />
34
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
45
public abstract class ApplicationCommandAttribute : Attribute
56
{
@@ -8,8 +9,10 @@ private protected ApplicationCommandAttribute(string name)
89
Name = name;
910
}
1011

12+
/// <inheritdoc cref="Rest.ApplicationCommandProperties.Name" />
1113
public string Name { get; }
1214

15+
/// <inheritdoc cref="Rest.ApplicationCommandProperties.DefaultGuildUserPermissions" />
1316
public Permissions DefaultGuildUserPermissions
1417
{
1518
get => _defaultGuildUserPermissions.GetValueOrDefault();
@@ -21,6 +24,7 @@ public Permissions DefaultGuildUserPermissions
2124

2225
internal readonly Permissions? _defaultGuildUserPermissions;
2326

27+
/// <inheritdoc cref="Rest.ApplicationCommandProperties.DMPermission" />
2428
[Obsolete($"Replaced by '{nameof(Contexts)}'.")]
2529
public bool DMPermission
2630
{
@@ -33,15 +37,22 @@ public bool DMPermission
3337

3438
internal readonly bool? _dMPermission;
3539

40+
/// <inheritdoc cref="Rest.ApplicationCommandProperties.DefaultPermission" />
3641
[Obsolete($"Replaced by '{nameof(DefaultGuildUserPermissions)}'.")]
3742
public bool DefaultPermission { get; init; } = true;
3843

44+
/// <inheritdoc cref="Rest.ApplicationCommandProperties.IntegrationTypes" />
3945
public ApplicationIntegrationType[]? IntegrationTypes { get; init; }
4046

47+
/// <inheritdoc cref="Rest.ApplicationCommandProperties.Contexts" />
4148
public InteractionContextType[]? Contexts { get; init; }
4249

50+
/// <inheritdoc cref="Rest.ApplicationCommandProperties.Nsfw" />
4351
public bool Nsfw { get; init; }
4452

53+
/// <summary>
54+
/// The ID of the guild where the application command is registered.
55+
/// </summary>
4556
public ulong GuildId
4657
{
4758
get => _guildId.GetValueOrDefault();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
namespace NetCord.Services.ApplicationCommands;
22

3+
/// <inheritdoc cref="Rest.EntryPointCommandProperties" />
34
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
45
public class EntryPointCommandAttribute(string name, string description) : ApplicationCommandAttribute(name)
56
{
7+
/// <inheritdoc cref="Rest.EntryPointCommandProperties.Description" />
68
public string Description { get; } = description;
79
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace NetCord.Services.ApplicationCommands;
22

3+
/// <inheritdoc cref="Rest.MessageCommandProperties" />
34
public class MessageCommandAttribute(string name) : ApplicationCommandAttribute(name)
45
{
56
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
namespace NetCord.Services.ApplicationCommands;
22

3+
/// <inheritdoc cref="Rest.SlashCommandProperties" />
34
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
45
public class SlashCommandAttribute(string name, string description) : ApplicationCommandAttribute(name)
56
{
7+
/// <inheritdoc cref="Rest.SlashCommandProperties.Description" />
68
public string Description { get; } = description;
79
}
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
namespace NetCord.Services.ApplicationCommands;
22

3+
/// <summary>
4+
/// Specifies metadata for a choice of a slash command parameter.
5+
/// </summary>
36
[AttributeUsage(AttributeTargets.Field)]
4-
public class SlashCommandChoiceAttribute(string name) : Attribute
7+
public class SlashCommandChoiceAttribute : Attribute
58
{
6-
public string Name { get; } = name;
9+
/// <summary>
10+
/// Name of the choice (1-100 characters).
11+
/// </summary>
12+
public string? Name { get; init; }
713
}

NetCord.Services/ApplicationCommands/SlashCommandParameterAttribute.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@
22

33
namespace NetCord.Services.ApplicationCommands;
44

5+
/// <summary>
6+
/// Specifies metadata for a parameter of a slash command.
7+
/// Use this attribute to configure how a parameter is presented and validated.
8+
/// </summary>
59
[AttributeUsage(AttributeTargets.Parameter)]
610
public class SlashCommandParameterAttribute : Attribute
711
{
12+
/// <summary>
13+
/// Name of the parameter (1-32 characters).
14+
/// </summary>
815
public string? Name { get; init; }
916

17+
/// <summary>
18+
/// Description of the parameter (1-100 characters).
19+
/// </summary>
1020
public string? Description { get; init; }
1121

22+
/// <summary>
23+
/// Maximum value permitted for the parameter.
24+
/// </summary>
1225
public double MaxValue
1326
{
1427
get => _maxValue.GetValueOrDefault();
@@ -20,6 +33,9 @@ public double MaxValue
2033

2134
internal readonly double? _maxValue;
2235

36+
/// <summary>
37+
/// Minimum value permitted for the parameter.
38+
/// </summary>
2339
public double MinValue
2440
{
2541
get => _minValue.GetValueOrDefault();
@@ -31,6 +47,9 @@ public double MinValue
3147

3248
internal readonly double? _minValue;
3349

50+
/// <summary>
51+
/// Maximum length of the parameter value (1-6000).
52+
/// </summary>
3453
public int MaxLength
3554
{
3655
get => _maxLength.GetValueOrDefault();
@@ -42,6 +61,9 @@ public int MaxLength
4261

4362
internal readonly int? _maxLength;
4463

64+
/// <summary>
65+
/// Minimum length of the parameter value (0-6000).
66+
/// </summary>
4567
public int MinLength
4668
{
4769
get => _minLength.GetValueOrDefault();
@@ -53,14 +75,26 @@ public int MinLength
5375

5476
internal readonly int? _minLength;
5577

78+
/// <summary>
79+
/// If the option is a channel type, the channels shown will be restricted to these types.
80+
/// </summary>
5681
public ChannelType[]? AllowedChannelTypes { get; init; }
5782

83+
/// <summary>
84+
/// Type reader for the parameter, used to convert the input value to the specified type.
85+
/// </summary>
5886
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
5987
public Type? TypeReaderType { get; init; }
6088

89+
/// <summary>
90+
/// Provider for choices for the parameter, allowing users to select from predefined options.
91+
/// </summary>
6192
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
6293
public Type? ChoicesProviderType { get; init; }
6394

95+
/// <summary>
96+
/// Provider for autocomplete functionality, allowing dynamic suggestions based on user input.
97+
/// </summary>
6498
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
6599
public Type? AutocompleteProviderType { get; init; }
66100
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
namespace NetCord.Services.ApplicationCommands;
22

3+
/// <summary>
4+
/// Sub slash command allowing to create nested slash commands within a slash command.
5+
/// </summary>
6+
/// <param name="name"><inheritdoc cref="Name" path="/summary" /></param>
7+
/// <param name="description"><inheritdoc cref="Description" path="/summary" /></param>
38
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
49
public class SubSlashCommandAttribute(string name, string description) : Attribute
510
{
11+
/// <summary>
12+
/// Name of the sub slash command (1-32 characters).
13+
/// </summary>
614
public string Name { get; } = name;
715

16+
/// <summary>
17+
/// Description of the sub slash command (1-100 characters).
18+
/// </summary>
819
public string Description { get; } = description;
920
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace NetCord.Services.ApplicationCommands;
22

3+
/// <inheritdoc cref="Rest.UserCommandProperties" />
34
public class UserCommandAttribute(string name) : ApplicationCommandAttribute(name)
45
{
56
}

0 commit comments

Comments
 (0)