Skip to content

Commit 6314716

Browse files
committed
Add enable/disable support to file upload component
Introduces a Disabled property and related methods (Enable, Disable, SetState) to DiscordFileUploadComponent, allowing the component to be enabled or disabled as needed. Also updates XML documentation for clarity.
1 parent 68e72fd commit 6314716

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

DisCatSharp/Entities/Components/DiscordFileUploadComponent.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23

34
using DisCatSharp.Enums;
45

@@ -36,7 +37,7 @@ public DiscordFileUploadComponent(string customId = null, int minOptions = 1, in
3637
}
3738

3839
/// <summary>
39-
/// Whether this select component is required. For modals.
40+
/// Whether this file upload component is required. For modals.
4041
/// </summary>
4142
[JsonProperty("required", NullValueHandling = NullValueHandling.Ignore)]
4243
public bool? Required { get; internal set; }
@@ -55,6 +56,37 @@ public DiscordFileUploadComponent(string customId = null, int minOptions = 1, in
5556
[JsonProperty("max_values", NullValueHandling = NullValueHandling.Ignore)]
5657
public int? MaximumValues { get; internal set; } = 1;
5758

59+
/// <summary>
60+
/// Whether this component can be used.
61+
/// </summary>
62+
[JsonProperty("disabled", NullValueHandling = NullValueHandling.Ignore)]
63+
public bool Disabled { get; internal set; }
64+
65+
/// <summary>
66+
/// Enables this component if it was disabled before.
67+
/// </summary>
68+
/// <returns>The current component.</returns>
69+
public DiscordFileUploadComponent Enable()
70+
=> this.SetState(false);
71+
72+
/// <summary>
73+
/// Disables this component.
74+
/// </summary>
75+
/// <returns>The current component.</returns>
76+
public DiscordFileUploadComponent Disable()
77+
=> this.SetState(true);
78+
79+
/// <summary>
80+
/// Enables or disables this component.
81+
/// </summary>
82+
/// <param name="disabled">Whether this component should be disabled.</param>
83+
/// <returns>The current component.</returns>
84+
public DiscordFileUploadComponent SetState(bool disabled)
85+
{
86+
this.Disabled = disabled;
87+
return this;
88+
}
89+
5890
/// <summary>
5991
/// Assigns a unique id to the components.
6092
/// </summary>

0 commit comments

Comments
 (0)