Skip to content

Commit 111978a

Browse files
Red-K0KubaZ2
andauthored
Full documentation for ApplicationCommand*.cs files (#94)
* Full documentation for ApplicationCommand*.cs files * fix newline Co-authored-by: Kuba_Z2 <[email protected]> * Changed documentation for ApplicationCommandInteractionData.cs * Added note for autocomplete interactions * Update NetCord/ApplicationCommandInteractionDataOption.cs --------- Co-authored-by: Kuba_Z2 <[email protected]>
1 parent 057887a commit 111978a

7 files changed

+146
-0
lines changed

NetCord/ApplicationCommandInteraction.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33

44
namespace NetCord;
55

6+
/// <summary>
7+
/// Acts as a base class for application commands, such as slash commands and message commands.
8+
/// </summary>
69
public abstract class ApplicationCommandInteraction : Interaction
710
{
811
private protected ApplicationCommandInteraction(JsonModels.JsonInteraction jsonModel, Guild? guild, Func<IInteraction, InteractionCallback, RestRequestProperties?, CancellationToken, Task> sendResponseAsync, RestClient client) : base(jsonModel, guild, sendResponseAsync, client)
912
{
1013
}
1114

15+
/// <summary>
16+
/// Holds the containing application command's data.
17+
/// </summary>
1218
public abstract override ApplicationCommandInteractionData Data { get; }
1319
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
namespace NetCord;
22

3+
/// <summary>
4+
/// Contains data for an invoked <see cref="Rest.ApplicationCommand"/>.
5+
/// </summary>
36
public class ApplicationCommandInteractionData(JsonModels.JsonInteractionData jsonModel) : InteractionData(jsonModel)
47
{
8+
/// <summary>
9+
/// The invoked <see cref="Rest.ApplicationCommand"/>'s ID.
10+
/// </summary>
511
public ulong Id => _jsonModel.Id.GetValueOrDefault();
612

13+
/// <summary>
14+
/// The invoked <see cref="Rest.ApplicationCommand"/>'s name.
15+
/// </summary>
716
public string Name => _jsonModel.Name!;
817

18+
/// <summary>
19+
/// The invoked <see cref="Rest.ApplicationCommand"/>'s type.
20+
/// </summary>
921
public ApplicationCommandType Type => _jsonModel.Type.GetValueOrDefault();
1022
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
namespace NetCord;
22

3+
/// <summary>
4+
/// Contains information on an <see cref="ApplicationCommandInteraction"/> parameter.
5+
/// </summary>
36
public class ApplicationCommandInteractionDataOption(JsonModels.JsonApplicationCommandInteractionDataOption jsonModel) : IJsonModel<JsonModels.JsonApplicationCommandInteractionDataOption>
47
{
58
JsonModels.JsonApplicationCommandInteractionDataOption IJsonModel<JsonModels.JsonApplicationCommandInteractionDataOption>.JsonModel => jsonModel;
69

10+
/// <summary>
11+
/// The parameter's name.
12+
/// </summary>
713
public string Name => jsonModel.Name;
814

15+
/// <summary>
16+
/// The parameter's type.
17+
/// </summary>
918
public ApplicationCommandOptionType Type => jsonModel.Type;
1019

20+
/// <summary>
21+
/// The parameter's value, <see langword="null"/> if omitted. When autocomplete is triggered for this parameter, the value is guaranteed to be non-<see langword="null"/>.
22+
/// </summary>
1123
public string? Value => jsonModel.Value;
1224

25+
/// <summary>
26+
/// A list of <see cref="ApplicationCommandInteractionDataOption"/> objects, if the option's <see cref="Type"/> is <see cref="ApplicationCommandOptionType.SubCommand"/> or <see cref="ApplicationCommandOptionType.SubCommandGroup"/>, otherwise empty.
27+
/// </summary>
1328
public IReadOnlyList<ApplicationCommandInteractionDataOption>? Options { get; } = jsonModel.Options.SelectOrEmpty(o => new ApplicationCommandInteractionDataOption(o)).ToArray();
1429

30+
/// <summary>
31+
/// If the user is currently typing in this option. Used for autocomplete interactions.
32+
/// </summary>
1533
public bool Focused => jsonModel.Focused;
1634
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,68 @@
11
namespace NetCord;
22

3+
/// <summary>
4+
/// Represents a command parameter's type.
5+
/// </summary>
36
public enum ApplicationCommandOptionType
47
{
8+
/// <summary>
9+
/// A sub-command.
10+
/// </summary>
11+
/// <remarks>
12+
/// If present, the root <see cref="ApplicationCommandInteraction"/> can no longer be invoked.
13+
/// </remarks>
514
SubCommand = 1,
15+
16+
/// <summary>
17+
/// A group of sub-commands.
18+
/// </summary>
19+
/// <remarks>
20+
/// If present, the root <see cref="ApplicationCommandInteraction"/> can no longer be invoked.
21+
/// </remarks>
622
SubCommandGroup = 2,
23+
24+
/// <summary>
25+
/// A <see cref="string"/> value.
26+
/// </summary>
727
String = 3,
28+
29+
/// <summary>
30+
/// An integral number in the range <c>-2^53</c> to <c>2^53</c>.
31+
/// </summary>
832
Integer = 4,
33+
34+
/// <summary>
35+
/// A <see langword="true"/> or <see langword="false"/> value.
36+
/// </summary>
937
Boolean = 5,
38+
39+
/// <summary>
40+
/// Any user.
41+
/// </summary>
1042
User = 6,
43+
44+
/// <summary>
45+
/// Any channel or category in the current guild.
46+
/// </summary>
1147
Channel = 7,
48+
49+
/// <summary>
50+
/// Any role in the current guild.
51+
/// </summary>
1252
Role = 8,
53+
54+
/// <summary>
55+
/// Any role in the current guild, or any user.
56+
/// </summary>
1357
Mentionable = 9,
58+
59+
/// <summary>
60+
/// A floating point number in the range <c>-2^53</c> to <c>2^53</c>.
61+
/// </summary>
1462
Double = 10,
63+
64+
/// <summary>
65+
/// A <see cref="NetCord.Attachment"/> object.
66+
/// </summary>
1567
Attachment = 11,
1668
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
11
namespace NetCord;
22

3+
/// <summary>
4+
/// Represents a permission override for a command in a guild.
5+
/// </summary>
36
public class ApplicationCommandPermission(JsonModels.JsonApplicationCommandGuildPermission jsonModel) : Entity, IJsonModel<JsonModels.JsonApplicationCommandGuildPermission>
47
{
58
JsonModels.JsonApplicationCommandGuildPermission IJsonModel<JsonModels.JsonApplicationCommandGuildPermission>.JsonModel => jsonModel;
69

10+
/// <summary>
11+
/// The ID of the override's relevant role, user, or channel, depending on the override's <see cref="Type"/>. May also be:
12+
/// <list type="bullet">
13+
/// <item>
14+
/// <term>
15+
/// <see langword="@everyone"/>
16+
/// </term>
17+
/// <description>
18+
/// Where it is equal to the ID of the override's relevant guild.
19+
/// </description>
20+
/// </item>
21+
/// <item>
22+
/// <term>
23+
/// 'All Channels'
24+
/// </term>
25+
/// <description>
26+
/// Where it is equal to the ID of the override's relevant guild - 1.
27+
/// </description>
28+
/// </item>
29+
/// </list>
30+
/// </summary>
731
public override ulong Id => jsonModel.Id;
832

33+
/// <summary>
34+
/// Indicates the scope of the permission override.
35+
/// </summary>
936
public ApplicationCommandGuildPermissionType Type => jsonModel.Type;
1037

38+
/// <summary>
39+
/// Indicates whether the override is intended to enable or disable a command.
40+
/// </summary>
1141
public bool Permission => jsonModel.Permission;
1242
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
namespace NetCord;
22

3+
/// <summary>
4+
/// Indicates the scope of an <see cref="ApplicationCommandPermission"/> object.
5+
/// </summary>
36
public enum ApplicationCommandGuildPermissionType
47
{
8+
/// <summary>
9+
/// Indicates that a permission is overriden for a specific role.
10+
/// </summary>
511
Role = 1,
12+
13+
/// <summary>
14+
/// Indicates that a permission is overriden for a specific user.
15+
/// </summary>
616
User = 2,
17+
18+
/// <summary>
19+
/// Indicates that a permission is overriden for a specific channel.
20+
/// </summary>
721
Channel = 3,
822
}

NetCord/ApplicationCommandType.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
namespace NetCord;
22

3+
/// <summary>
4+
/// Indicates how a command is invoked client-side.
5+
/// </summary>
36
public enum ApplicationCommandType
47
{
8+
/// <summary>
9+
/// Slash command. Displayed when a user types <c>/</c> in chat.
10+
/// </summary>
511
ChatInput = 1,
12+
13+
/// <summary>
14+
/// UI-based. Displayed when right clicking or tapping on a user.
15+
/// </summary>
616
User = 2,
17+
18+
/// <summary>
19+
/// UI-based. Displayed when right clicking or tapping on a message.
20+
/// </summary>
721
Message = 3,
822
}

0 commit comments

Comments
 (0)